实体框架向导在MySQL上崩溃 [英] Entity Framework wizard crashes on MySQL
问题描述
我的问题类似于这一个但崩溃后发生。我必须在SQL Server和MySQL之间互操作一个EF数据库优先模型。更具体地说,我的应用程序根据连接字符串和配置设置( DB_TYPE = MYSQL
等)向SQL Server或MySQL触发了纯SQL查询,同时具有两个数据库结构和维护在一起,以便对每个模式的修改重新应用到另一个。
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.
现在我使用SQL Server数据库优先模型为应用程序添加了EF支持。我必须现在让应用程序也运行在MySQL上。为了验证旧的开发人员没有留下两个DBMS之间的错位,我试图根据数据库更新模型
*,这次我选择了MySQL连接到我的开发数据库在本地主机。
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.
在下面的屏幕上点击下一个
之后,它将简单崩溃并返回到EDMX编辑器
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.
这是我的Web.config片段:
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>
我如何解决我的问题?我重新安装了Visual Studio的MySQL工具,但没有帮助。
How can I solve my problem? I reinstalled MySQL tools for Visual Studio but didn't help.
*我使用本地化版本的Visual Studio,所以我不知道所有命令的原始英语
*I use a localized version of Visual Studio, so I don't know the original English for all commands
推荐答案
当你看看这似乎是一个常见的问题。我以这种方式沿着这条路径知道,但是晚点更好,然后永远不会。
When you look around this seems to be a common problem. I know this way along the trail but late is better then never.
我最终删除并重新安装了visual studio 2015和mysql,然后从头开始。然后,我确保我走过的过程只引入了所需要的。
I eventually removed and reinstalled visual studio 2015 and mysql and then started from scratch. I then ensured that I walked through the process bringing in only what was needed.
- 使用nuget安装MySql.Data 6.9.9和MySql.Data.Entity 6.9.9。没有其他的。
- Nuget不会正确更改网络配置,因此您需要更改如下。
之前
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
之后
<entityFramework>
<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>
这修复了我。我不确定你需要重新安装,但确定你需要做第2步。
This fixed it for me. I am not sure that you need do the reinstall, but for sure you need do step 2.
祝你好运。
这篇关于实体框架向导在MySQL上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!