views:

285

answers:

1

Hello,

I'm messing around with MVC 2.0 on VS2010 and am having an issue getting the clean web config feature working.

Basically in my Web.debug.config I have

<connectionStrings xdt:Transform="Replace">
  <add name="ApplicationServices" 
    connectionString="Server=localhost;Database=SITE_DB;User ID=dbuser;Password=P@ssw0rd;Trusted_Connection=False;" />
</connectionStrings>

and in my Web.config I have

      <connectionStrings>
        <add name="ApplicationServices"
             connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
             providerName="System.Data.SqlClient" />
      </connectionStrings>

When I run the site in debug mode, I'd expect that xdt:Transform="Replace" would replace the entire connectionStrings section with what is in the Web.debug.config.

Am I assuming wrong? Or am I doing something else incorrect. Not much info posted around this and I'd figure I'd ask you guys.

A: 

i think you need to put xdt:Locator="Match(name)" in

<connectionStrings xdt:Transform="Replace" xdt:Locator="Match(name)">   
    <add name="ApplicationServices" 
      connectionString="Server=localhost;Database=SITE_DB;
      User ID=dbuser;Password=P@ssw0rd;Trusted_Connection=False;" 
     /> 
</connectionStrings>
schrodinger's code
@schrodinger's code what happens if he wants to replace everthing in the connectionStrings element? right now, the Match(name) wouldn't work, right? becuase it's trying to look for an _attribute_ on the connectionStrings _element_ called 'name' .. which doesn't exist. that attrib exists in the <add> _child_ elements .. ??? (just thinking out a-loud, here...)
Pure.Krome