5

I am having a weird issue with MySql Connector(6.8.3) and EF6. I was working on a WebApi project where I use MySql and EF6 with Database first approach. Everything worked fine[even deployed on one of the test servers] until I changed the database from 'Test' database to 'Production' database [just the database name] in the connection string and updated the model[just to see nothing is broken!]. After that, it failed to connect to database. So, I changed the connection string back and rebuilt the solution, then I got bunch of 'Mapping' warnings. I deleted the model and tried to create the model again from the database. Now, I am getting the following 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

Here is the config file

    <!-- 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>
      <clear/>
      <remove invariant="MySql.Data.MySqlClient"/>
      <add name="MySql.Data.MySqlClient" description="ADO.Net driver for MySQL" invariant="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,Version=6.8.3.0, Culture=neutral,PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <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>

I tried reinstalling the connector and EF from Nuget, but nothing changed. Can someone please let me know whats going on?

Thanks

usp
  • 797
  • 3
  • 10
  • 24
  • I am still trying to resolve this issue! appreciate any help or suggestions? – usp Feb 14 '14 at 21:08
  • make sure that your project contains a reference to the MySQL EF provider - the message indicates that EF Designer cannot find the provider it can use to talk to the database. Once you have the provider in your project make sure to **build** the project before starting the wizard. This step is very important. – Pawel Feb 17 '14 at 23:15
  • Problem seems like this: https://entityframework.codeplex.com/workitem/1869 – Kuzgun Feb 20 '14 at 10:00
  • @Pawel it worked fine until I changed the connection string. I didn't change anything except the connection!! – usp Feb 24 '14 at 15:32
  • @Kuzgun might be. but I am not sure! – usp Feb 24 '14 at 15:32

3 Answers3

3

I had a similar issue, I had the MySql connector referenced to my project with Nuget. But the server had another version of MySql connector installed in the machine itself. So the application gave priority to the MySql connector installed in GAC of server.

All you have to do is either

Uninstall the MySql connector in Server

or

Install suitable MySql connector (in your case v6.8.3) in server and uninstall the rest

or

change your provider type version to one that is installed in the server.

Sen Jacob
  • 3,384
  • 3
  • 35
  • 61
  • I am not sure you followed the question! I was able to test the app fine with the the Test DATABASE connection. It was when I changed the connection string to the Production DATABASE, the problem started. It has nothing to do with any server!! My qpp is not even deployed anywhere. I am debugging it from my dev machine. – usp Feb 24 '14 at 15:24
  • Nothing against @Sen Jacob.....i am not sure who awarded the 'bounty'. But, it was funny since this answer is not even related to my issue!! – usp Feb 24 '14 at 15:26
  • @usp I've flagged the answer to get attention of moderators. I presume they'll remove the bounty – Sen Jacob Feb 26 '14 at 07:57
3

Bloody hell, had the same issue.

I'm pretty new to the .NET environment so, I don't know how the packages manager and all work but it seems that when I import the assemblies for the MySQL connector, it updates the "web.conf" file with the wrong parameters for the provider.

In my case, using EF6 and MySQL Connector for EF v6.8.3.0, the following worked for me :

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
        <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider>
    </providers>
</entityFramework>

Hope it helps someone

wiwi
  • 270
  • 2
  • 9
  • What version of MySql for Visual Studio did you use? I am on 1.2.3 with 6.8.3 and I still get the error. I have this as well. I tried 6.9.2 RC and it failed too. – Gaʀʀʏ Aug 20 '14 at 04:51
0

i know what the problem is, you have to do the next steps : 1. Right click on the project 2. Manage NuGet Packages 3.remove the MySql.Data 4.now you can do what you wanted to do 5.after you finish, go back to Manage NuGet Packages and add MySql.Data.Entity :)

good luck nofar eliasi

Nofar Eliasi
  • 109
  • 5