Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dotnet ef core 生成实体
#公共的依赖
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
#MySQL
Install-Package Pomelo.EntityFrameworkCore.MySql
Scaffold-DbContext -Force "server=localhost;database=netnrf;uid=root;pwd=123;" Pomelo.EntityFrameworkCore.MySql
#SQLServer
Install-Package Microsoft.EntityFrameworkCore
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Scaffold-DbContext -Force "server=localhost;database=netnrf;uid=sa;pwd=123;" Microsoft.EntityFrameworkCore.SqlServer
#PostgreSQL
Install-Package Npgsql.EntityFrameworkCore.PostgreSQL
Scaffold-DbContext -Force "Host=localhost;Database=netnrf;Username=postgres;Password=123" Npgsql.EntityFrameworkCore.PostgreSQL
#参数
-OutputDir *** 实体文件所存放的文件目录
-ContextDir *** DbContext文件存放的目录
-Context *** DbContext文件名
-Schemas *** 需要生成实体数据的数据表所在的模式
-Tables *** 需要生成实体数据的数据表的集合
-DataAnnotations
-UseDatabaseNames 直接使用数据库中的表名和列名(某些版本不支持)
-Force 强制执行,重写已经存在的实体文件
#help
https://www.cnblogs.com/yangjinwang/p/9516988.html
http://www.npgsql.org/efcore/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.