Could not connect to MySQL through EF6 in Visual Studio 2013

老子叫甜甜 提交于 2019-12-09 10:48:03

问题


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 :

  • MySQL for Visual Studio 1.1.1
  • MySQL Connector/Net 6.8.

The error says :

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 e.g 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'.

can anyone help me to identify what should i do then ?


回答1:


This worked for me WITHOUT reinstalling the Visual Studio or anything what so ever.

  • 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>




回答2:


I resolved the same way as above.

My step for example:

  • Install latest EntityFramework using NuGet
  • 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>




回答3:


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



来源:https://stackoverflow.com/questions/37688023/could-not-connect-to-mysql-through-ef6-in-visual-studio-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!