实体框架ADO.NET Sql.Data.Client提供者未找到 [英] Entity Framework ADO.NET Sql.Data.Client provider not found
问题描述
我也有类似的问题,因为psented的问题之一$ P $ <一href="http://stackoverflow.com/questions/18455747/no-entity-framework-provider-found-for-the-ado-net-provider-with-invariant-name">No发现ADO.NET提供与固定名称System.Data.SqlClient的实体框架提供的错误有以下消息:
I have a similar problem as the one presented in the question No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient', the error has the following message:
ADO.NET提供与固定名称System.Data.SqlClient的要么是没有在机器或应用程序的配置文件中注册,或无法加载。详情请参阅内部异常。
"The ADO.NET provider with invariant name 'System.Data.SqlClient' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details."
随着答案的相关问题提示,我重新安装实体框架(EF6)通过包管理器控制台,但错误依然存在。我还检查了EntityFramework.SqlServer.dll在我的项目中引用。 这里是连接字符串存储在App.config中:
As the answers to the related question suggest, I have reinstalled Entity Framework (EF6) via the Package Manager Console, but the error persists. I also checked that EntityFramework.SqlServer.dll is referenced in my project. Here is the connection string as stored in App.config:
<add name="DesignModel" ConnectionString="metadata=res://*/DesignModel.csdl|res://*/DesignModel.ssdl|res://*/DesignModel.msl;provider=System.Data.SqlClient;provider connection string="data source=C071E;initial catalog=CTD2;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
我有我曾经的EntityFramework创建完全相同的实体和上下文中的另一个项目,它工作得很好,这使得这一切更令人费解。
I have another project where I used EntityFramework to create the exact same entities and context, and it works fine, which makes this all more puzzling.
试图执行此线时显示错误:
The error is shown when trying to execute this lines:
DesignModel designContext = new DesignModel();
designContext.MoPerfIDs.Load();
在这里DesignModel是继承的DbContext类的名称。
where DesignModel is the name of the class that inherits DbContext.
下面是完整的App.config:
Here's the full App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ppe.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DesignModel" connectionString="metadata=res://*/DesignModel.csdl|res://*/DesignModel.ssdl|res://*/Design Model.msl;provider=System.Data.SqlClient;provider connection string="data source=MONNMC071E;initial catalog=CTD2;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlClient" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
任何帮助将AP preciated。先谢谢了。
Any help will be appreciated. Thanks in advance.
推荐答案
您需要注册的实体框架提供了System.Data.SqlClient的SQL连接类型。 你应该在的app.config:
You need to register the Entity Framework provider for the System.Data.SqlClient SQL connection type. you should have in app.config:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
这篇关于实体框架ADO.NET Sql.Data.Client提供者未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!