【问题标题】:error There is a duplicate 'entityFramework' section defined错误定义了重复的“实体框架”部分
【发布时间】:2014-01-21 08:25:37
【问题描述】:

我收到此错误:

Config Error       There is a duplicate 'entityFramework' section defined
Config File    \\?\D:\koopaproject\koopaproject\web.config
9: <!--For more information on Entity Framework configuration, visit     http://go.microsoft.com/fwlink/?LinkID=237468--> 
10:  <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />11:   </configSections>

在我的 web.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>

<connectionStrings>
    <add name="koopaco.com_koopaContext" connectionString="Data Source=localhost;Initial   Catalog=koopaco.com_koopa;Persist Security Info=True;User ID=koopaco.com_zohre;Password=136613;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>

我安装了:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
    </dependentAssembly>
</assemblyBinding>

但我仍然收到此错误。

【问题讨论】:

  • 您是否检查了父文件夹或 machine.config 中的 web.configs 未指定实体框架部分?
  • 什么意思?它是父文件夹中的网络配置。我做了上面所说的所有事情。
  • 根目录下的配置文件呢? %systemroot%\Microsoft.NET\Framework\v4.0.30319\Config\machine.config %systemroot%\Microsoft.NET\Framework\v4.0.30319\Config\web.config
  • 我检查了 web.config 并在 machine.config 中添加了实体框架部分和程序集,但它没有改变。
  • 可能与:stackoverflow.com/questions/19324333/… 相关(目前在“相关”列表中排名第 6)。

标签: entity-framework


【解决方案1】:

我也遇到了同样的问题。我的问题的原因是,当我通过 IIS(作为默认网站下的应用程序)运行应用程序时,根目录中有一个 Web.config,其中也定义了 &lt;entityFramework&gt; 部分。

从根目录下删除了Web.config,问题就解决了。

【讨论】:

    【解决方案2】:

    将此添加到 web.config 文件中

    <entityFramework xdt:Transform="RemoveAll" />
    

    【讨论】:

      【解决方案3】:

      如果您在 IIS Express 中进行测试时遇到此问题,请在 IIS Express 使用的更高级别的“web.config”中查找冲突。我发现我在 C:\Users\yourUserIDHere\Documents\IISExpress\config**applicationhost.config** 中有问题。

      applicationhost.config 是 IIS Express 的一种更高级别的 web.config。

      在那里定义了我的站点,并在我的 C: 驱动器上保留了一个文件夹位置,我过去曾在其中运行过我的项目的旧副本。

      【讨论】:

        【解决方案4】:

        将此添加到 web.release.config 文件中

        <entityFramework xdt:Transform="RemoveAll" />
        

        这样当你部署 web 应用程序时 entityFramework 不会出现在 web 应用程序的配置文件中

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-04-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-04-20
          相关资源
          最近更新 更多