Register entityFramework with MySql.Data 6.7.2.0 connector


Question

I have tried to configure my web project to use MySQL pre release of .net connectors, version 6.7.2.0. However, i keep getting this message, even if I try my best configure my project to use the 6.7.2.0 version of the connectors.

As it is now, I keep getting this errormessage:

No Entity Framework provider found for 'MySql.Data.MySqlClient' ADO.NET provider. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

I have tried different ways to configure my Web.config file, and here is my current settings:

  <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.7.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
  <entityFramework>
    <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
  </entityFramework>

I have installed EF6 alfa3 from NuGet. Currently my connector has been installed manually from this downloaded file, I tried to install it from NuGet repository, but with the exact same result.

Accepted Answer

In addition to registering the ADO.NET provider, you need to register the Entity Framework provider:

<entityFramework>
  <providers>
    <provider invariantName="MySql.Data.MySqlClient"
              type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
  </providers>
</entityFramework>

You also need to ensure that the provider has been built against Entity Framework 6. See this article for more information on this.


Popular Answer

I had a similar issue. After rolling back to EF5 and MySql Connector 5.6 and it still not working, I finally found a feed where someone had mentioned that they had to remove the version and culture reference in order to get it to work. No idea why. Here:

 <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, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
   <entityFramework>
<defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />





Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why