简体   繁体   English

MySQL实体框架错误 - 在配置中找不到指定的商店提供程序,或者无效

[英]MySQL Entity Framework Error - The specified store provider cannot be found in the configuration, or is not valid

I have written an assembly in C# to perform all data access for a MySQL database. 我在C#中编写了一个程序集来执行MySQL数据库的所有数据访问。 I have successfully used the assembly (a compiled dll) in my C# winform desktop application. 我在C#winform桌面应用程序中成功使用了程序集(已编译的dll)。 But it only works on PCs that have had the "MySQL Connector Net 6.4.4" installed. 但它仅适用于安装了“MySQL Connector Net 6.4.4”的PC。

I tried to use the same assembly with my asp.net Website project. 我试图在我的asp.net网站项目中使用相同的程序集。 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. 通过将MySQL连接字符串添加到web.config文件可以轻松解决这个问题。 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. 我现在得到这个错误(下面列出的堆栈跟踪),我已经尝试将以下dll添加到我的bin文件夹来解决它,但它不起作用。

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 

But it only works on PCs that have had the "MySQL Connector Net 6.4.4" installed. 但它仅适用于安装了“MySQL Connector Net 6.4.4”的PC。

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. 在这种情况下,您还必须在配置文件中注册提供程序,因为安装会将其添加到machine.config,如果您没有安装它,则提供程序当前未注册。

Try to add this to your web.config file: 尝试将此添加到您的web.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.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  </DbProviderFactories>
</system.data>

I found I had this issue too when using the standalone .NET connector 6.6.5 installer. 我发现在使用独立的.NET连接器6.6.5安装程序时也遇到了这个问题。

To resolve, simply uninstall the standalone .NET connector installer, and install the mysql-community-installer, this installer lets you add/remove features to MySQL, and in it one of the features is the .NET connector that has Entity Framework support. 要解决此问题,只需卸载独立的.NET连接器安装程序,然后安装mysql-community-installer,此安装程序允许您向MySQL添加/删除功能,其中一个功能是具有Entity Framework支持的.NET连接器。

Once you use this connector all your MySQL EF issues go away. 一旦使用此连接器,所有MySQL EF问题都将消失。

Add this in web config 在web配置中添加此项

 <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data" />
    </DbProviderFactories>
  </system.data>

For people that reach this old question via Google like I did: 对于像我这样通过Google解决这个老问题的人:

You will also get this error if you upgrade to MySQL for Visual Studio 1.1.3, which is the first compatible version with Visual Studio 2013, but still use MySQL Connector 6.6.6, which as far as I know is the last version that was compatible with Entity Framework 4.3.1. 如果为Visual Studio 1.1.3升级到MySQL,也会出现此错误,这是Visual Studio 2013的第一个兼容版本,但仍然使用MySQL Connector 6.6.6,据我所知,它是最后一个版本与Entity Framework 4.3.1兼容。

We knew we had to update to EF5 (or 6) ASAP, but now this is forcing the change upon us at a very inconvenient time... 我们知道我们必须尽快更新到EF5(或6),但现在这迫使我们在非常不方便的时候改变...

I had this error (I was using .net connector 6.4.3) after uninstalling all .net frameworks and reinstalling them. 在卸载所有.net框架并重新安装它们之后,我遇到了这个错误(我正在使用.net连接器6.4.3)。 The fix was to uninstall 6.4.3 and install 6.6.5 解决方法是卸载6.4.3并安装6.6.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有oracle的EF-“在配置中找不到指定的存储提供程序,或者它无效。” - EF with oracle - “The specified store provider cannot be found in the configuration, or is not valid.” EntityFramework,在配置中找不到指定的商店提供商,或者无效 - EntityFramework,The specified store provider cannot be found in the configuration, or is not valid 找不到实体框架提供者 - No Entity Framework Provider Found 在配置中更改实体框架提供程序 - Change Entity Framework provider in configuration 指定的命名连接在配置中找不到,不打算与EntityClient提供程序一起使用,或者无效 - The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid 实体框架提供程序错误 - Entity Framework provider error 未找到具有不变名称&#39;MySql.Data.MySqlClient&#39;的ADO.NET提供程序的实体框架提供程序-WCF - No Entity Framework provider found for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient' - WCF 实体框架Include():指定的包含路径无效 - Entity Framework Include() : A specified Include path is not valid Oracle 实体框架“指定的强制转换无效” GetDecimal - Oracle Entity Framework 'Specified cast is not valid' GetDecimal 指定的强制转换是无效的 C# 实体框架 - Specified cast is not valid C# Entity Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM