Mig*_*uev 16 .net c# entity-framework
我有一个问题类似于 No Entity Framework提供者为ADO.NET提供程序找到的具有不变名称'System.Data.SqlClient'的问题,该错误有以下消息:
"具有不变名称'System.Data.SqlClient'的ADO.NET提供程序未在机器或应用程序配置文件中注册,或者无法加载.有关详细信息,请参阅内部异常."
正如相关问题的答案所示,我已经通过软件包管理器控制台重新安装了实体框架(EF6),但错误仍然存在.我还检查了我的项目中引用了EntityFramework.SqlServer.dll.这是存储在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" />
Run Code Online (Sandbox Code Playgroud)
我有另一个项目,我使用EntityFramework创建完全相同的实体和上下文,它工作正常,这使得这更令人费解.
尝试执行此行时会显示错误:
DesignModel designContext = new DesignModel();
designContext.MoPerfIDs.Load();
Run Code Online (Sandbox Code Playgroud)
其中DesignModel是继承DbContext的类的名称.
这是完整的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>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.提前致谢.
哇……这很特别……无论如何。您需要为System.Data.SqlClientSQL 连接类型注册实体框架提供程序。
您想将以下内容添加到您的app.config/web.config
<configuration>
<configSections>
<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.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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
41367 次 |
| 最近记录: |