实体框架向导在 MySQL 上崩溃
我的问题类似于,典型的崩溃原因是 MySQL 连接器和 MySQL.Data.Entity 的版本不匹配.
您得到错误版本的最可能原因是包名从 MySQL.Data.Entity 更改为 MySql.Data.EntityFramework.
我花了很多时间来尝试线程中的答案,所以仅供参考.
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
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
解决方案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.
相关文章