MySQL Forums
Forum List  »  MySQL for Visual Studio

Re: EF6 Code First with MySQL
Posted by: Gabriela Martinez Sanchez
Date: November 14, 2014 09:44AM

Hi Gabriel:

Could you please share us the code of the entities before doing the changes and then the code that is throwing you the error?

Also here are the steps that you should do to use EF migrations:

Add the MySql.Data.Entity.EF6 reference to your project.
Set up the MySQL provider in your app.config or web.config file:

<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider>
</providers>
</entityFramework>

After running the enable-migrations command set up the sql and code generators on the configuration constructor:

Add the namespace
using MySql.Data.Entity;

and modify the Configuration constructor to be like this:

public Configuration()
{
AutomaticMigrationsEnabled = false;

SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator()); CodeGenerator = new MySql.Data.Entity.MySqlMigrationCodeGenerator();
}


Then you can run the migrations commands correctly.

Options: ReplyQuote


Subject
Views
Written By
Posted
3243
November 13, 2014 01:21AM
1400
November 13, 2014 01:36AM
Re: EF6 Code First with MySQL
1653
November 14, 2014 09:44AM
2199
November 18, 2014 02:17AM
1113
November 26, 2014 07:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.