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
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.
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
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
来源:https://stackoverflow.com/questions/21680548/mysql-connector-with-ef-6