星空网 > 软件开发 > 数据库

Mysql 6.7.7 + EntityFramework 5.0 Code First 不能 Update

1、修改 Migrations/Configuration.cs 文件

 1 namespace DataModel.Migrations 2 { 3   using System; 4   using System.Data.Entity; 5   using System.Data.Entity.Migrations; 6   using System.Linq; 7  8   internal sealed class Configuration : DbMigrationsConfiguration<DataModel.SpaceDataContext> 9   {10     public Configuration()11     {12       AutomaticMigrationsEnabled = true;13 14       AutomaticMigrationDataLossAllowed = true;15       16       SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator());  // This will add our MySQLClient as SQL Generator  17     }18 19     protected override void Seed(DataModel.SpaceDataContext context)20     {21       // This method will be called after migrating to the latest version.22 23       // You can use the DbSet<T>.AddOrUpdate() helper extension method 24       // to avoid creating duplicate seed data. E.g.25       //26       //  context.People.AddOrUpdate(27       //   p => p.FullName,28       //   new Person { FullName = "Andrew Peters" },29       //   new Person { FullName = "Brice Lambson" },30       //   new Person { FullName = "Rowan Miller" }31       //  );32       //33     }34   }35 }

 

2、修改 App.config 文件 entityFramework 节点

1  <entityFramework>2   <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />3   <contexts>4    <context type="DataModel.SpaceDataContext,DataModel">5     <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[DataModel.SpaceDataContext,DataModel], [DataModel.Migrations.Configuration,DataModel]], EntityFramework" />6    </context>7   </contexts>8  </entityFramework>

 

3、完事!! 注意红色高亮处哦

  




原标题:Mysql 6.7.7 + EntityFramework 5.0 Code First 不能 Update

关键词:MYSQL

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

陆勇:我不是药神,我是中国商人!:https://www.ikjzd.com/articles/22327
日本站如何注册?2019年亚马逊日本站注册资料及流程!:https://www.ikjzd.com/articles/22328
最强背书! Anker上架苹果官方商店!:https://www.ikjzd.com/articles/22330
6个最常见的亚马逊产品投放促销错误,你中招了?:https://www.ikjzd.com/articles/22331
小白必看:亚马逊Listing优化你真的做好了吗?:https://www.ikjzd.com/articles/22332
2019年,我们如何做好阿里巴巴国际站?:https://www.ikjzd.com/articles/22333
黄果树瀑布景区景点 - 黄果树瀑布景区景点分布图:https://www.vstour.cn/a/408258.html
延边酒店(附近旅馆住宿50元):https://www.vstour.cn/a/409226.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流