其他分享
首页 > 其他分享> > .net core 自动生成EF代码(net core 3.0更改)

.net core 自动生成EF代码(net core 3.0更改)

作者:互联网

NuGet:管理控制台 

输入:

sqlserver
EntityFramework,Microsoft.EntityFrameworkCore.Tools

PM > Scaffold-DbContext "Data Source=127.0.0.1;Initial Catalog=Test1;User ID=sa;Password=123456;MultipleActiveResultSets=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

mysql
安装 MySql.Data.EntityFrameworkCore,Microsoft.EntityFrameworkCore.Tools

Scaffold-DbContext "server=127.0.0.1;port=3306;user=root;password=123;database=jstest" MySql.Data.EntityFrameworkCore -OutputDir Entitys

 

//命令格式为:

 //Scaffold-DbContext "数据库连接字符串" EF组件名(Microsoft.EntityFrameworkCore.SqlServer/Pomelo.EntityFrameworkCore.MySql/等等) -OutputDir 输出文件夹名称

net core 3.0 mysql
Install-Package Pomelo.EntityFrameworkCore.MySql -Version 3.0.0

Scaffold-DbContext "server=127.0.0.1;port=3306;user=root;password=test;database=test" Pomelo.EntityFrameworkCore.MySql -OutputDir Entitys

标签:core,Scaffold,EF,DbContext,Microsoft,EntityFrameworkCore,MySql,net,OutputDir
来源: https://www.cnblogs.com/wangqing01/p/12973569.html