C# EntityFramework,配置中找不到指定的store provider,或者无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15878578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 18:15:18  来源:igfitidea点击:

EntityFramework,The specified store provider cannot be found in the configuration, or is not valid

c#entity-frameworkexception

提问by jeff

I have a Winform application and am using EntityFramework. The application runs just fine in my dev machine but when I try to run at client's machine I get "The specified store provider cannot be found in the configuration, or is not valid" error. I have distributed EntityFramework.dll with the client. Why am I getting this error? I am not putting the connection strings in the app.config file as it is dynamically created based on the database selected at runtime.(I am using VistaDB as database)

我有一个 Winform 应用程序并且正在使用 EntityFramework。该应用程序在我的开发机器上运行得很好,但是当我尝试在客户端机器上运行时,我收到“在配置中找不到指定的商店提供程序,或无效”错误。我已经与客户端分发了 EntityFramework.dll。为什么我收到这个错误?我没有将连接字符串放在 app.config 文件中,因为它是根据运行时选择的数据库动态创建的。(我使用 VistaDB 作为数据库)

The app.config is below:

app.config 如下:

<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
 </connectionStrings>
 <entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>

回答by Jay

based on which type of DataBase you use you need to provide Db ORM settings that is going to used by Entityframe work

根据您使用的数据库类型,您需要提供 Entityframe 工作将使用的 Db ORM 设置

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

回答by H2ONaCl

I had this problem. I uninstalled Connector .NET and reinstalled it. Now it works.

我有这个问题。我卸载了 Connector .NET 并重新安装了它。现在它起作用了。

回答by Mehdy.Rahimy

To solve this error, install Microsoft SQL Server Compact 4.0on your client's computer.

要解决此错误,请在客户端计算机上安装Microsoft SQL Server Compact 4.0