ASP.NET web.confg避免继承configSections

时间:2017-04-12 08:47:08

标签: asp.net entity-framework web-config iis-7.5

这是我的父网站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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="elmah">
        <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
        <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
        <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
    </sectionGroup>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <section name="Duncan.PEMS.Web.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
</configSections>
.....
.....
.....
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
.....
.....
.....

我的孩子网站web.config

<configSections>
    <remove name="entityFramework" />
    <!-- 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.LocalDbConnectionFactory, EntityFramework">
        <parameters>
            <parameter value="PemsUsProEntities" />
        </parameters>
    </defaultConnectionFactory>
    <providers>
    </providers>
</entityFramework>

这里的问题是父站点需要EF 5.0,而子站点需要EF 6.0。我想知道我是否可以在我的孩子身上覆盖它而不触及我父网站上的任何内容?

我在configSections中的子<remove name="entityFramework" />中尝试web.config,但它说

  

已定义了部分或组名'entityFramework'。更新到   这可能只发生在定义它的配置级别。

我正在使用IIS 7.5

0 个答案:

没有答案