'system.data.entity.internal.appconfig'的类型初始值设定项引发了异常。 C# [英] the type initializer for 'system.data.entity.internal.appconfig' threw an exception. c#

查看:84
本文介绍了'system.data.entity.internal.appconfig'的类型初始值设定项引发了异常。 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version="1.0" encoding="utf-8"?>

<configuration>
  <appSettings>

  </appSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <connectionStrings>
    <add name="FeedAccountEntities" connectionString="metadata=res://*/FeedAccountsDetails.csdl|res://*/FeedAccountsDetails.ssdl|res://*/FeedAccountsDetails.msl;provider=System.Data.SqlClient;provider connection string='data source=NGWS23\SQLEXPRESS;initial catalog=FeedAccount;persist security info=True;user id=sa;MultipleActiveResultSets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />

  </connectionStrings>

  <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.SqlConnectionFactory, EntityFramework" />

  </entityFramework>

</configuration>

推荐答案

只需删除entityFramwork部分下的提供程序,它对我有用



Just remove the provider under the entityFramwork section, It worked for me

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






您的App.config文件中列出了Entity Framework 6.0,您的代码中的某些项目仍然保留在旧版本的EF上,并期望在App.config文件中找到它。反之亦然。



检查版本
Hi,

Your App.config file has Entity Framework 6.0 listed, and some project in your code is still holding onto EF with an older version and expecting to find it in the App.config file. Or vice versa.

Check for the versions


这篇关于'system.data.entity.internal.appconfig'的类型初始值设定项引发了异常。 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆