简体   繁体   中英

MySQL Provider errors in Entity Framework 5.0

I'm using Entity Framework 5.0 with MySQL 6.8.3

I've already copy both MySql.Data.dll and MySql.Data.Entity.dll to Output folder. On my PC, I add following code to 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. 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.

For anyone has the same problem with me, just specific the version of MySQL dll in your provider configuration:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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