2

I have a Visual Studio 2017 project that has Entity Framework 6.2

When trying to create the edmx file I get the error

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

I have had this many times but it has always been fixed by using the dlls from the connector installation folder and making some changes to the app.config

However I can not get it to work this way now. I have no idea what to try next... I am using MYSQL 8.0.12

This is my app.config

<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> <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> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-8.0.12.0" newVersion="8.0.12.0" /> </dependentAssembly> <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> </configuration> 
2
  • If you have 6.2, why does the redirect point to newVersion="6.0.0.0"? Commented Sep 8, 2018 at 19:50
  • EFs nuget package adds that at install time. It has always been like that even when everything worked okay. Commented Sep 8, 2018 at 23:19

1 Answer 1

2

Not sure if this is still solved are not. However, the below solution might be helpful for someone who is struggling.

It doesn't matter if you have installed any version of connector as it is not being automatically referenced in VS 2017. Only thing that matters is "MySQL for Visual Studio".

  1. Install "MySQL for visual studio" (preferably any latest version 1.2.8 or 2.0.5) In case you face any issue while trying to install 2.0.5 please follow this link : https://forums.mysql.com/read.php?174,664930,664971

  2. Inside your project, Add Nuget References to "MySQL.Data.EntityFrameWork" (V 8.0.13 or higher)

It will by default create the below App.Config file

<?xml version="1.0" encoding="utf-8"?> <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> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="mssqllocaldb" /> </parameters> </defaultConnectionFactory> <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.EntityFramework, Version=8.0.13.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"> </provider></providers> </entityFramework> </configuration>

And there you go.. It should work fine. I have spent more than 2 days, searching the entire google (almost) to figure that all the references/directions/suggestions were all pointing out "MySql.Data.Entity.EF6".. While all the while it is "MySql.Data.EntityFramework" that works fine with VS 2017

Sign up to request clarification or add additional context in comments.

2 Comments

This is pretty helpful. On top of this, if you are updating your project from MySql.Data 6.0.X to 8.0.X, delete your EntityFramework, MySql.Data, and MySql.Data.EF6. Go through your App.Config and Web.Config and remove all sections related to MySql and entityFramework except for your connectionStrings which you can keep. Then, when you add EntityFramework and MySql.Data.EntityFramework all the sections in your config will be correct.
You need to uninstall and reinstall MySQL for Visual Studio to trigger an update in Visual Studio. Now, if you are connected to your database in View -> Server Explorer, you can configure your App.config by clicking the blue MySQL Application Configuration tool button that will appear in your Solution Explorer. Your project needs to reference the Entity Framework Nuget and the MySQL.Data and MySQL.Data.EntityFramework DLLs that are in your installed connector folder. dev.mysql.com/doc/visual-studio/en/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.