Code First Migrations更新数据库架构

一、确保解决方案可以生成成功

二、打开程序包管理器控制台

三、默认项目选择DataContext所在项目

四、运行命令Enable-Migrations,会在项目自动创建迁移配置,修改配置

AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;

 

五、运行命令Update-Database,执行迁移。

六、结束

原文地址:https://www.cnblogs.com/baobao2010/p/2970889.html