No Entity Framework provider found for 'MySql.Data.MySqlClient' ADO.NET provider

I'm trying to use Entity Framework with MySQL and I get the above error. I have the latest MySQL connector installed.

The full error reads:

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.

However, I can't find anything that suggests just how you register it in the 'entityFramework' section.

Some other posts (example) suggest adding the provider to the system.Data DbProviderFactories section like this:

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

But that doesn't work because it claims that the invariant name is duplicated. And, if I actually iterate through the System.Data.Common.DbProviderFactories I can see the last one is the MySQL provider:

MySQL Data Provider
.Net Framework Data Provider for MySQL
MySql.Data.MySqlClient
MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d

So the provider is there, but EF refuses to use it. Any ideas?

My full config looks like this:

<configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>

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

<connectionStrings>
    <add name="myContext" connectionString="server=****;User Id=****;password=****;Persist Security Info=True;database=myDb"
  providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>

</entityFramework>

</configuration>

in EF5 or less, all ok. in EF6, you need to use mysql connector 6.8.x, and add DbConfigurationTypeAttribute to you DbContext:

[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class DemoContext : DbContext{}

which MySqlEFConfiguration is in MySql.Data.Entity.EF6.dll in 6.8.x. Have a try!


You need to create this section in config (EF 5):

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

Update: Use this definition for EF 6:

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

Thanks to elcool.


I just had the same situation when trying to configure Visual Studio Professional 2017 environment with MySQL, ADO.NET (Database First) and EF6.

After going through hell with every connector/NET available, I got it to work with Connector/NET v6.9.10 and following the steps below.

  1. Uninstall/remove "Connector/NET" and "MySQL for Visual Studio" if installed.

  2. Install "MySQL for Visual Studio" v2.0.5 CTP (MySQL for Visual Studio). Note: Install MySQL for Visual Studio before Connector/NET.

  3. Install "Connector/NET" v6.9.10 (Connector/Net). https://i.stack.imgur.com/XOT1I.jpg Note: I tried using Connector/NET v6.8, v6.10 and v8 first, but none of them worked Here you can find all Connector Versions and Compatibilities with Visual Studio IDEs, but so far this list is inaccurate.

  4. Download and Install "EntityFramework" v6.2.0 through NuGet.

  5. Add references to C:\Program Files (x86)\MySQL\Connector.NET 6.9.10\Assemblies\v4.5\MySql.Data.dll and C:\Program Files (x86)\MySQL\Connector.NET 6.9.10\Assemblies\v4.5\MySql.Data.Entity.EF6.dll.

  6. Add MySQL EF6 provider info inside App.config under entity framework providers as follow:

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

And that was it. VS2017 was ready to go for me. Hope this works for everybody, as it did for me today.

References:

  1. Can't Create Entity Data Model - using MySql and EF6

  2. No Entity Framework provider found for 'MySql.Data.MySqlClient' ADO.NET provider


Just adding a summary of versions (since I saw you are trying 6.2 which is way too old)

  • For EF4, use Connector/NET 6.6.x (current GA is 6.6.6)
  • For EF5, use Connector/NET 6.7.x (current GA is 6.7.4) or Connector/NET 6.8.x (current GA is 6.8.3).
  • For EF6, use Connector/NET 6.8.x (current GA is 6.8.3).