I am trying to connect to MYSQL Database using EF6 in visual studio , later i was using SQL and it worked fine afterwards i shifted to Mysql then i install such this required components :
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 tried possible online solutions eg reinstall this components but it did not work , Otherwise this i tried to add such this code to my App.config
:
<configuration> <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> </configuration>
but it face the same destiny, or event clear all entity tags from my app.config
. also i tried to install later version of entity such :
Install-Package EntityFramework -Version 5.0.0
but it get : Install failed. Rolling back... Install-Package : Already referencing a newer version of 'EntityFramework'.
Install failed. Rolling back... Install-Package : Already referencing a newer version of 'EntityFramework'.
can anyone help me to identify what should i do then ?
This worked for me WITHOUT reinstalling the Visual Studio or anything what so ever.
<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>
I resolved the same way as above.
My step for example:
Install latest MySql.Data.Entity
Add reference all the 4 files in C:\\Program Files (x86)\\MySQL\\MySQL Connector Net 6.8.3\\Assemblies\\v4.5
Replace the entityFramework in Web.config as below:
<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>
if you have updated your MySQL to 8.0 and facing issues in Visual Studio EntityFramework integration, then I have successfully integrated and recorded all my steps.
Follow this to get your issue solved: https://gist.github.com/pishangujeniya/41a051572a471fa0311a8f4f6d0c5332
For anyone else with the same issue I had, VS2019's Manage Nuget Packages window kinda hid the package I needed and I made a couple of bad assumptions. I was creating a .Net Framework class library to wrap my DB, and the Nuget packages for 8.20.0 are named differently than 6.xx I needed MySql.Data and MySql.Data.EntityFramework. The second one has a version for .Net Core with the similar name MySql.Data.EntityFrameworkCore. Pity there isn't better error reporting.
I solve the problem by merge some solutions :) use this steps:
<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework" />
</providers>
</entityFramework>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.