1. Modify the Migrations/configuration.cs file
1 namespacedatamodel.migrations2 {3 usingSystem;4 usingSystem.Data.Entity;5 usingSystem.Data.Entity.Migrations;6 usingSystem.Linq;7 8 Internal Sealed classConfiguration:dbmigrationsconfiguration<datamodel.spacedatacontext>9 {Ten PublicConfiguration () One {automaticmigrationsenabled = true;13 automaticmigrationdatalossallowed = true;15 Setsqlgenerator ("MySql.Data.MySqlClient", New MySql.Data.Entity.MySqlMigrationSqlGenerator ()); //This would add our mysqlclient as SQL Generator - } - + protected Override voidSeed (datamodel.spacedatacontext context) - { + //This method is called after migrating to the latest version. A at //You can use the dbset<t>. AddOrUpdate () Helper extension method - //To avoid creating duplicate seed data. e.g. - // - //context. People.addorupdate ( - //p = p.fullname, - //new Person {FullName = "Andrew Peters"}, in //new Person {FullName = "Brice Lambson"}, - //new Person {FullName = "Rowan Miller"} to // ); + // - } the } *}
2. Modify the app. Config file entityframework node
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, Finished!! Pay attention to the red highlights!
Mysql 6.7.7 + entityframework 5.0 Code First does not solve the problem update-database