1、安装EntityFramework包
通过NuGet添加程序包:
Microsoft.EntityFrameworkCore;
Microsoft.EntityFrameworkCore.SqlServer;
Microsoft.EntityFrameworkCore.Tools;
Microsoft.EntityFrameworkCore.Design;
2、同步数据结构
在EFCoreContext中注册 public DbSet< UpgradeFile > UpgradeFile { get; set; }(不能遗漏,这是在数据库中创建表的映射元数据)
进行特殊列转换的配置,例如:long型在数据库中存bigint
怎么同步:
1、通过工具菜单-》NuGet包管理器-》程序包管理控制台
2、选择默认EFCore项目,并且将EFCore项目设置为启动项
3、Install-Package Microsoft.EntityFrameworkCore.Tools
4、add-migration 【快照名称(随意)】
5、update-database
6、如果失败的话,可以remove-migration重新来