简体   繁体   English

实体框架5.0中的MySQL提供程序错误

[英]MySQL Provider errors in Entity Framework 5.0

I'm using Entity Framework 5.0 with MySQL 6.8.3 我正在将Entity Framework 5.0与MySQL 6.8.3结合使用

I've already copy both MySql.Data.dll and MySql.Data.Entity.dll to Output folder. 我已经将MySql.Data.dll和MySql.Data.Entity.dll复制到Output文件夹。 On my PC, I add following code to App.Config: 在我的PC上,我向App.Config添加以下代码:

<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"/>
  </DbProviderFactories>
</system.data>

It works fine, but when I bring it to another PC, I must remove that config to make it worked. 它可以正常工作,但是当我将其带到另一台PC时,必须删除该配置才能使其正常工作。 How can I make it worked without adding or removing that config? 如何在不添加或删除该配置的情况下使其工作?

I've figured out my problem. 我已经解决了我的问题。 This issue was due to conflict of MySQL in project and Connector/Net. 此问题是由于项目和Connector / Net中的MySQL冲突引起的。

For anyone has the same problem with me, just specific the version of MySQL dll in your provider configuration: 对于任何与我有相同问题的人,只需在您的提供程序配置中指定MySQL dll的版本即可:

<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.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
  </DbProviderFactories>
</system.data>

This version should be same as the dll that your project references. 此版本应与您的项目引用的dll相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM