您的位置:首页 > 产品设计 > UI/UE

连接MySQL数据库得到错误“Unable to find the requested .Net Framework Data Provider”

2014-11-10 18:53 561 查看
 

Registering DbProviderFactories

Each .NET Framework data provider that supports a factory-based class registers configuration information in the DbProviderFactories section of the machine.config file on the local computer. The following configuration file fragment shows the syntax and format for System.Data.SqlClient.

<system.data>
<DbProviderFactories>
<add name="SqlClient Data Provider"
invariant="System.Data.SqlClient"
description=".Net Framework Data Provider for SqlServer"
type="System.Data.SqlClient.SqlClientFactory, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</DbProviderFactories>
</system.data>


The invariant attribute identifies the underlying data provider. This three-part naming syntax is also used when creating a new factory and for identifying the provider in an application configuration file so that the provider name, along with its associated connection string, can be retrieved at run time.

 

我下载MySQL连接器/净6.7.4Visual Studio 1.0.2 MySQL随后,然后这些指令测试:

创建一个连接到现有的MySQL数据库。

创建一个控制台应用程序。

添加麻烦。网络实体数据模型从现有数据库连接。

添加代码生成项EF 5。x DbContext发生器,取代了。tt文件。

编写一些代码,从数据库中检索记录。

运行应用程序时,我得到了这个异常:


ConfigurationErrorsException:没有找到或加载注册。净框架数据提供商。



然后我添加引用
MySql.Data
MySql.Data.Entity
6.7.4.0我库版本。NET 4.5项目。现在,当运行应用程序时,我得到一个不同的异常:


FileLoadException:无法加载文件或组装的MySql。数据、Version = 6.6.5.0 c5687fc88969c44d文化=中立,不能删除!请教如何解决这个问题”或它的一个依赖项。位于议会的清单定义不匹配装配参考。(从HRESULT例外:0 x80131040)



注意版本号,这不是MySQL连接器,我已经安装的版本。

我如何得到它正常工作?

 

诀窍解决这是:

添加引用
MySql.Data
MySql.Data.Entity
库(6.7.4.0正确的版本。NET 4.5,在我的例子中)这一项目。

编辑
machine.config
与你的编辑器以管理员身份运行,和替换出现的所有MySQL版本
6.6.5.0
通过
6.7.4.0
 .

第二步,注意,有多个
machine.config
文件,一个用于每个框架版本(3.0,3.5,4.0)和结构(32位,64位)。还要注意的是
machine.config
文件。NET 4.5的。NET 4.0文件夹。你可以找到的
machine.config
文件:


C:\Windows\ Microsoft.NET \ Framework \ \配置



和:


C:\Windows\ Microsoft.NET \ Framework64 \ \配置



如果没有对MySQL的引用
machine.config
文件,您可能没有安装MySQL为Visual Studio。这样做,或添加以下的
app.config
您的项目的文件:

<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐