Mysql 6.7.7 + entityframework 5.0 Code First does not solve the problem update-database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.