dotnet core EF命令

dotnet 3.1 之后,需要升级 dotnet ef命令

dotnet tool install --global dotnet-ef


命令使用帮助
dotnet ef dbcontext scaffold -h

Arguments:
参数:
The connection string to the database.
数据库连接字符串
The provider to use. (E.g. Microsoft.EntityFrameworkCore.SqlServer)
提供程序类型

Options:
其他选项:
-d|–data-annotations Use attributes to configure the model (where possible). If omitted, only the fluent API is used.
数据注释使用属性来配置模型(如果可能)。如果省略,则只使用fluent API。

-c|–context The name of the DbContext.
DbContext 的名称

–context-dir The directory to put DbContext file in. Paths are relative to the project directory.
DbContext 的路径

-f|–force Overwrite existing files.
覆盖已经存在的文件

-o|–output-dir The directory to put files in. Paths are relative to the project directory.
输出目录

–schema … The schemas of tables to generate entity types for.
要为其生成实体类型的表的架构。

-t|–table … The tables to generate entity types for.
要生成实体代码的表的名称 支持视图名称
多个table用多个-t

–use-database-names Use table and column names directly from the database.
使用数据库名称

–json Show JSON output.
输出内容,以json显示

-p|–project The project to use.
项目名称

-s|–startup-project The startup project to use.
开始项目名称(不太明白)

–framework The target framework.
framework的版本

–configuration The configuration to use.
配置信息

–runtime The runtime to use.
运行版本(??)

–msbuildprojectextensionspath The MSBuild project extensions path. Defaults to “obj”.
–no-build Don’t build the project. Only use this when the build is up-to-date.
-h|–help Show help information
-v|–verbose Show verbose output.
–no-color Don’t colorize output.
–prefix-output Prefix output with level.

sql server---------------------------------------------------------------
dotnet ef dbcontext scaffold “Server=(local);Database=lun;User ID=sa;Password=;” Microsoft.EntityFrameworkCore.SqlServer -o models -c Lun_DbContext

my sql---------------------------------------------------------------
Scaffold-DbContext “server=127.0.0.1;uid=root;pwd=1234123;database=shop” Pomelo.EntityFrameworkCore.Mysql -f -o Shop/Models

你可能感兴趣的:(c#,.net,core)