ASP.NET MVC 2中的Web.config转换和额外的Web.config文件

我正在尝试在.NET 4上运行的ASP.NET MVC 2项目中使用Web.config转换。但是,我遇到了一个问题:
// Root Web.config
<add name="MyDB" connectionString="default...default" />


// Root Web.Debug.config
<add name="MyDB" connectionString="debug...debug" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />

// Root Web.Release.config
<add name="MyDB" connectionString="release... release" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
我一直收到这个错误:   警告源文档中的任何元素都不匹配'/ configuration / add [@ name ='MyDB']'C: filePath Web.Release.config 我将其缩小到Views文件夹中的Web.Config文件。如果我给它一个connectionString,比如根Web.config文件中的那个,那么一切都很好,但这意味着我必须维护两个Web.config文件。这有什么解决方案吗?难道我做错了什么?     
已邀请:
不确定为什么视图文件夹中的web.config被牵连但是从错误中你得到它听起来好像你在web.config中的元素和转换配置文件之间不匹配。 在web.config中,假设
<add />
<connectionStrings />
的孩子你会做:
<?xml version="1.0" encoding="utf-8"?>

<configuration>

...

    <connectionStrings>
        <add name="SomeName" providerName="System.Data.SqlClient" connectionString="SomeConnectionString" />
    </connectionStrings>

...

</configuration>
并在web.debug.config中
<?xml version="1.0" encoding="utf-8"?>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

...

    <connectionStrings>
        <add xdt:Locator="Match(name)" xdt:Transform="SetAttributes(connectionString)" name="SomeName" connectionString="SomeOtherConnectionString" />
    </connectionStrings>

...

</configuration>
    
正如我已经说过: 不要忘记从原始的“web.config”手动复制“配置”的所有其他属性,因为看起来VS2012不会自动执行,因此不会匹配...     

要回复问题请先登录注册