Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework wizard crashes on MySQL

Tags:

My question is similar to this one but the crash happens later. I must interoperate an EF database-first model between SQL Server and MySQL. More specifically, my application had plain SQL queries fired to either SQL Server or MySQL according to connection string and configuration setting (DB_TYPE=MYSQL, etc.), having both databases with same structure and maintained together, so that each modification to one's schema was reapplied to the other.

Now I added EF support to the application using SQL Server database-first model. I must now let the application run on MySQL too. In order to verify that the old developer didn't leave something disaligned between the two DBMSes, I tried to Update model against database* and this time I selected the MySQL connection to my development database on localhost.

After I click Next on the screen below, it will simply crash and return to EDMX editor

Data Model wizard

I need to go ahead with the project, I'm stuck on this since a while.

Here is my Web.config fragment:

<entityFramework>     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">       <parameters>         <parameter value="v11.0" />       </parameters>     </defaultConnectionFactory>     <providers>       <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />       <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />     </providers>   </entityFramework>   <system.data>     <DbProviderFactories>       <remove invariant="MySql.Data.MySqlClient" />       <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />     </DbProviderFactories>   </system.data> 

How can I solve my problem? I reinstalled MySQL tools for Visual Studio but didn't help.

*I use a localized version of Visual Studio, so I don't know the original English for all commands

like image 222
usr-local-ΕΨΗΕΛΩΝ Avatar asked Jan 25 '15 18:01

usr-local-ΕΨΗΕΛΩΝ


People also ask

Is entity framework compatible with MySQL?

The Code First approach enables you to define an entity model in code, create a database from the model, and then add data to the database. MySQL Connector/NET is compatible with multiple versions of Entity Framework Core.

Why does MySQL keeps crashing?

You are running many mysqld servers using the same data directory on a system that does not support good file system locks (normally handled by the lockd lock manager), or you are running multiple servers with external locking disabled.


2 Answers

I have no idea why this works but I went in to my NuGet Package Manager and removed the MySql.Data.Entity (also checked dependencies which removed MySql.Data). I went into my .edmx and ran the 'Update model from database...' and everything worked.

(Note: This also removed my entity framework so I had to add that back in using the NuGet Manager)

W...T...F?

Maybe others can confirm this...

like image 98
Ian Newland Avatar answered Sep 18 '22 12:09

Ian Newland


It has been answered in another thread, the typical crash reason is the mismatched versions of MySQL connector and MySQL.Data.Entity.

And most likely reason for you to get the wrong version is because of the package name changed from MySQL.Data.Entity to MySql.Data.EntityFramework.

I was spending a lot of time on trying the answers in the thread, so just FYI.

like image 36
Keep Thinking Avatar answered Sep 21 '22 12:09

Keep Thinking