Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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?
–
–
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.
–
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)
–
–
<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.
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
Right click on the solution (top level in the solution explorer).
Manage Nuget packages for solution.
Go to Installed tab.
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.
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)
–
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.
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.
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
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.
After adding a project, Use nuget console to add EntityFramework6.1.3, by install-package EntityFramework
User Console to add MySQL reference by MySQL.Data.Entity
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>
At this point make sure you rebuild your project. (It's a must)
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
<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>
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.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.