1. Need to go to the official download MySQL connect/.net driver, address: Http://cdn.mysql.com//Downloads/Connector-Net/mysql-connector-net-6.9.9.msi
2. Create a simple project and refer to the file:
3. Enable Data migration: Enable-migrations-force
will prompt the error, you need to modify the configuration file, follow the steps to process
3.1 Comment out the default provider, if not, add it manually
<providers>
<provider invariantname= "MySql.Data.MySqlClient" type= "MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6 "/>
</providers>
3.2 Adding a connection string
<connectionStrings>
<add name= "Default" connectionstring= "SERVER=52.XXX.126;DATABASE=DB; Uid=root; pwd=xxx; "Providername=" MySql.Data.MySqlClient "/>
</connectionStrings>
4. Create a new entity class:
4. New DbContext (need to add a feature: [Dbconfigurationtype (typeof (MySql.Data.Entity.MySqlEFConfiguration))], otherwise the error:
After completing the above steps, when we run Add-migration adduser it is already possible to migrate successfully and then run Update-database. At this point the database will appear the entity we just added user
Ef6+mysql Code First