MySQL 实体框架错误 - 在配置中找不到指定的存储提供程序,或无效 [英] MySQL Entity Framework Error - The specified store provider cannot be found in the configuration, or is not valid

查看:40
本文介绍了MySQL 实体框架错误 - 在配置中找不到指定的存储提供程序,或无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 C# 编写了一个程序集来执行 MySQL 数据库的所有数据访问.我已经在我的 C# winform 桌面应用程序中成功使用了程序集(一个编译的 dll).但它仅适用于安装了MySQL Connector Net 6.4.4"的 PC.

I have written an assembly in C# to perform all data access for a MySQL database. I have successfully used the assembly (a compiled dll) in my C# winform desktop application. But it only works on PCs that have had the "MySQL Connector Net 6.4.4" installed.

我尝试在我的 asp.net 网站项目中使用相同的程序集.首先,我收到一个关于缺少连接字符串的错误.这很容易通过将 MySQL 连接字符串添加到 web.config 文件来解决.我现在收到此错误(下面列出了堆栈跟踪),我尝试将以下 dll 添加到我的 bin 文件夹中以解决它,但它没有用.

I tried to use the same assembly with my asp.net Website project. Firstly I got an error about a missing connection string. This was easily solved by adding the MySQL connection string to the web.config file. I now get this error (stack trace listed below), I have tried adding the following dlls to my bin folder to resolve it but it didn't work.

MySql.Data.dll
MySql.Data.Entity.dll
MySql.Web.dll

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. 
---> System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. 
---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed. at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at System.Data.EntityClient.EntityConnection.GetFactory(String providerString) 
--- End of inner exception stack trace 

推荐答案

但它仅适用于安装了MySQL Connector Net 6.4.4"的 PC.

But it only works on PCs that have had the "MySQL Connector Net 6.4.4" installed.

这是否意味着您正在尝试在未安装提供程序的机器上运行您的代码?在这种情况下,您还必须在配置文件中注册提供程序,因为安装会将其添加到 machine.config 中,如果您没有安装它,则当前未注册提供程序.

Does it mean that you are trying to run your code on machine where the provider is not installed? In such case you must also register the provider in your configuration file because installation adds it to machine.config and if you didn't install it the provider is currently not registered.

尝试将其添加到您的 web.config 文件中:

Try to add this to your web.config file:

<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.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  </DbProviderFactories>
</system.data>

这篇关于MySQL 实体框架错误 - 在配置中找不到指定的存储提供程序,或无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆