21
votes

I am attempting to connect to MySQL through a C# .NET web MVC application.

My issue is that, when I attempt to add an ADO.NET Entity Data Model, generated from Database, based on my MySQL connection, I get the following error message:

Your project references the latest version of Entity Framework; however, an Entity Framework database provider compatible with this version could not be found for you data connection. Exit this wizard, install a compatible provider, and rebuild your project before performing this action

I'm running the following software, upgrades & add-ons:

  • Visual Studio 2013
  • MySQL Server v5.6.21
  • MySQL For Visual Studio v1.2.3
  • Connector/NET v6.9.4

NuGet packages:

  • EntityFramework v6.1.1
  • MySQL.Data v6.9.3
  • MySQL.Data.Entities v6.8.3.0
  • SQL.Web v6.9.3

My web.config, entityFramework block:

    ..
</system.webServer>
<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" />
  </providers>
</entityFramework>
<runtime>
    ..

I have looked at all other solutions I could find here on SO and generally through google, tried all of them and none of the solutions seems to have worked or have been for very different versions of Connector/NET or other of the programs needed.

Can anyone spot what I am doing wrong?

15
I suggest to install the latest MySQL for Visual Studio version (1.2.3). It's looks like your installed 1.1.1 is not compatible with installed Connector/NET v6.9.4, see (Table 4.1): dev.mysql.com/doc/connector-net/en/… - Rimas
Hi there - I just checked up on it, and evidently I do have MySQL for Visual Studio v1.2.3 already. Thanks though! :) - Eax

15 Answers

8
votes

Basic solution is to reinstall MySQL and VisualStudio including Entity and .NET.

For some reason, I am not certain why, the installation process corrupts the DLLs, or at least that is the experience I had and other colleagues. Our solution has been to try all of above with to no avail. So in the end we tried to reinstall, and it worked. So try that :)

23
votes

I had the same issue. After installing:

  • Visual Studio 2013 Community Edition
  • MySQL for Visual Studio 1.2.3
  • MySQL Connector .NET 6.9.5

I didn't want to reinstall Visual Studio, so after some tests, I found that the folder "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies" contained old versions of the following files:

  • MySql.Data.dll
  • MySql.Data.Entity.EF6.dll
  • MySql.Web.dll

After closing Visual Studio, I replaced these files with those in "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.9.5\Assemblies\v4.5", and now it works!

Note: replace 6.9.5 in the subfolder name above, with the actual version installed in your system.

18
votes

This worked for me WITHOUT reinstalling the Visual Studio or anything what so ever.

  • installed latest MySQL visual studio plugin and MySQL connector net
  • removed the entityFramework Tag in App.config or Web.config and all its child tags.
  • replaced it with the following code:
<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" />
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  </providers>
</entityFramework>
  • added MySql.Data.dll, MySql.Data.Entity.EF6.dll, and MySql.Web.dll(if not WPF app) references to the project.
  • rebuilt the project and then added the ado.net model.

NOTE: Make sure you remove only the entityFramework tag and its children, and replace it with the snipped above. If you delete any "extra" tags you might have even bigger problems with your project, like I did. X)

3
votes

Just add to web.config:

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

Do not forget to rebuild the solution before attempt to add an ADO.NET Entity Data Model, generated from Database, again.

3
votes

I've encountered the same problem. Fortunately, I fixed it. The MySql.Data.dll or MySql.Data.Entity.EF6.dll is not compatible to EF 6.1 up version. What I did, I installed EF version 6.0.0.0 in nuget console by this command -> install-package entityframework -version 6.0.0.0 and it fixed the issue.

1
votes

If you need to use the EntityFramework with a mysql Database you just need to install an older version of EntityFramework like v 5.0 with the package manager console. Write Install-Package EntityFramework -Version 5.0.0. Enjoy. https://www.nuget.org/packages/EntityFramework/5.0.0

1
votes

Now this isn't an issue I've had myself, but I did find the following possible solution:

  1. Right click on the solution (top level in the solution explorer).
  2. Manage Nuget packages for solution.
  3. Go to Installed tab.
  4. For all of the EntityFramework related packages (MySql.Data, MySql.Data.Entities, MySql.ConnectorNET.Entity and MySql.ConnectorNET.Data), select them then select the "Manage" button.
  5. Enable each package for all projects.

What I noticed here was that he had two extra packages you haven't mentioned "MySql.ConnectorNET.Entity" and "MySql.ConnectorNet.Data". It could be that you are missing these and they are needed to work with Entity Framework 6.1.1

(Source: No Entity Framework Provider Found For)

0
votes

I have a working Project with version 6.8.3 of MySQL Connector Libraries and EF6 v6.0.0. I remember this error, I think I solved adding some line to app.config manually.

I list you the lines in my app.config related to EF6 and MySQL Configuration, are different to yours, maybe it helps you:

<configSections>
    ...

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
    </providers>
</entityFramework>

I had installed MySQL Connector Net 6.8.3 with the package dowloaded from MySQL site, and added two references to the Project: MySql.Data and MySql.Data.Entity.EF6, both 6.8.3 versión (I notice you are using different versions of this files...).

I added EF6 (v 6.0.0) to the project via Nuget.

Are not the latest versions, but hope this helps.

0
votes

Solution is to add this to app.config / web.config on the project your are trying to add/modify data model.

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

change version according to your connector.

0
votes

first of all, re-install vs 1.2.3, adding The following References to your project or check it versions:

MySql.Data.dll

MySql.Data.Entity.EF6.dll

MySql.Web.dll

Remove the default entityFramework tag in App.config or Web.config Rebuild your project, you can add ADO.NET Entity Data Model

0
votes

I was using visual studio 2013 community. Wanted to do Code First on MySQL db. I was having the same problem of "Your project references the latest version of Entity Framework;..." What solved my problem were simple steps given below.

  1. After adding a project, Use nuget console to add EntityFramework6.1.3, by install-package EntityFramework
  2. User Console to add MySQL reference by MySQL.Data.Entity
  3. Open your Web.config or App.config to change the entityframework and system.data sections as given below

            <entityFramework>
            <defaultConnectionFactory  type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"  />
            <providers>
                <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer" />
                <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
            </provider>
            </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.7.0,       Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
            </DbProviderFactories>
        </system.data>
    
  4. At this point make sure you rebuild your project. (It's a must)

  5. Now add ADO Entity Models and chose MySQL and it works.

By the way the plugins I use are M4VS 1.2.3 and MySQL .NET Connector 6.9.7

0
votes

Quite simply I was using Nuget to reference the MySQL.dll (etc) and it automatically referenced the .net 4.0 dll's. I just changed the references to 4.5 and it worked.

0
votes

do in nuget command line

update-package -reinstall -ignoreDependencies

and rebuild solution this work or me

0
votes

I added this which solved it for me:

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
0
votes

There are still problems in 2018...

DB-first scenario: for Visual Studio 2017 Community Edition I found working combination:

  • MySQL for Visual Studio 1.2.8
  • MySQL Connector .NET 6.9.9
  • EntityFramework 5.0.0 (I`ve tryed different combinations for v6.x with no luck)

Code-First scenario I can run using official documentation https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html with the latest Connector v.8.0.11 and EF6.