无法通过Visual Studio 2013中的EF6连接到MySQL
我试图在Visual Studio中使用EF6连接到MYSQL数据库,后来我使用SQL,然后工作正常,之后转移到Mysql,然后安装了这样的必需组件:
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 :
- 用于Visual Studio 1.1.1的MySQL
- MySQL Connector/Net 6.8.
错误提示:
您的项目引用了Entity Framework的最新版本;但是,找不到与您的数据连接兼容的Entity Framework数据库提供程序.退出此向导,安装兼容的提供程序,并在执行此操作之前重建项目
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
我尝试了可能的在线解决方案,例如 reinstall 该组件,但无法正常工作,
否则,我试图将这样的代码添加到我的App.config
:
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>
<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>
但它面临着相同的命运,或者从我的app.config
中清除所有实体标签.
我也尝试安装更高版本的实体,例如:
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 :
安装包EntityFramework-版本5.0.0
Install-Package EntityFramework -Version 5.0.0
但它得到了:Install failed. Rolling back...
Install-Package : Already referencing a newer version of 'EntityFramework'.
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 ?
这对我有用,而无需重新安装Visual Studio或任何其他方式.
This worked for me WITHOUT reinstalling the Visual Studio or anything what so ever.
- 安装了最新的MySQL Visual Studio插件和MySQL连接器网
- 删除了App.config或Web.config中的entityFramework标签及其所有子标签.
- 将其替换为以下代码:
- 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>
<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>