【问题标题】:Configuration Error: Error for provider in web.config配置错误:web.config 中的提供程序错误
【发布时间】:2014-06-24 12:31:23
【问题描述】:

我正在从 entityframework 6.1.0 迁移到 entityframework 5.0.0。我已经成功安装了EntityFramework 5.0.0。

现在我在 web.config 中遇到问题。

这是我的 web.config:

<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>

<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />

<connectionStrings>
<add name="MusicStoreEntities" connectionString="data source=(LocalDb)\v11.0;initial catalog=MvcMusicStore;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MvcMusicStore.mdf" providerName="System.Data.SqlClient" />

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

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

我在使用 EF 6.1.0 之前没有这个问题。

我搜索了很多,但找不到解决问题的方法。

谢谢...

【问题讨论】:

  • 这就是你的整个 Web.config 文件?
  • 您在 Visual Studio 中得到的确切错误消息是什么?
  • @MichaelPerrenoud:复制操作执行得不好。现在你可以看到我的 web.config
  • @LenielMacaferi:EntityFramework.dll 和 web.config 中无法识别的元素“提供者”中出现“System.TypeInitializationException”类型的第一次机会异常
  • 你的问题很可能是&lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;;旧版本中的命名空间可能不同。

标签: c# asp.net-mvc entity-framework provider


【解决方案1】:

删除

<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>

这里是来自 EF 网站的更多信息,关于 Providers 仅在 EF 6 中需要。


确保您已安装 LocalDb NuGet 包:

Install-Package Microsoft.AspNet.Providers.LocalDb

【讨论】:

  • 我已经尝试删除它,但连接到 db 时出现问题
  • 初始化数据库时出现异常
  • @bahar_Agi 当然...但是我们需要确切的错误消息,例如内部异常...
  • 无法确定存储版本;需要有效的存储连接或版本提示。
  • @bahar_Agi:与您的问题相关:tech.trailmax.info/2014/02/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-04
  • 2015-06-12
相关资源
最近更新 更多