I have a site running in a subdirectory of another site. They run in separate app pools. The two sites are running different versions of Entity Framework. So in the web.config in the subdirectory I have:
<remove name="entityFramework"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
But even with the <remove>
tag I still get this error:
Section or group name 'entityFramework' is already defined. Updates to this may only occur at the configuration level where it is defined.
I've also placed <location>
tags in the parent web.config wherever possible:
<location path="." inheritInChildApplications="false">
The <location>
tag is present around the parent web.config's <entityFramework>
section.
And I've placed enableConfigurationOverride="false"
in the applicationHost.config files for IIS (both files in System32 and SysWOW64).
How do I prevent the site in the subdirectory from seeing the parent entityFramework
tag?
EDIT
IIS Version: 7.5.7600.16385
From the parent web.config:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
l
<location path="." inheritInChildApplications="false">
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</location>
From the child web.config:
<configSections>
<remove name="entityFramework"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
l
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
EDIT 2
In regards to using <clear/>
: this causes a series of errors about missing section declarations. If I add back ~100 lines of section declarations I get the error: An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
The error persists even if I use <validation validateIntegratedModeConfiguration="false" />
in <system.webServer>
.
Can you confirm if you tried clear
instead of remove
the problem still persist or not?
<configSections>
<clear/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
You might read more here
Hope this will help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With