MVC:重复 Entity Framework 节

MVC: Duplicate Entity Framework Section

我有一个 MVC 应用程序,它 运行 来自我的 IIS 实例的根目录,可以正常工作,没有任何问题。

我已将另一个应用程序作为一个单独的应用程序部署到该应用程序的子文件夹中 运行。 'root' 应用程序工作正常,但当我尝试打开另一个应用程序时,我收到“500.19 - 内部服务器错误”,告诉我我有一个重复的 entity framework 部分。

查看之前的问题,我看到了各种建议,但其中 none 似乎有效。

更多信息 - 这是 'root' 应用程序的部分。

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

这是另一个:-

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

我试过:-

如有任何帮助,我们将不胜感激。

我相信这个错误实际上是在抱怨文字 <entityFramework> 部分,而不是 <configSections> 节点中的部分定义。但是,如果子应用程序的配置中有任何特定内容,则简单地将其从子应用程序中删除可能会产生副作用。在这种情况下最好的办法是关闭父级中的继承 Web.config:

<entityFramework inheritInChildApplications="false">
    ...
</entityFramework>

不幸的是,没有办法完全关闭继承,因此您需要根据需要继续将此属性添加到父节点 Web.config,直到子应用程序最终加载。