title: Web.config Build vs Release transform not working
body: <p>I have an ASP.NET Web Application project that connects to a remote database via the Entity Framework. During debugging (eg running the project on my local computer), the IP address to the database is different than during release (eg after uploading the project to my webserver and running it from the browser). Until now I have always manually changed the database connection string in the Web.config file to switch between the two (basically I had to connection strings, one named 'Debug' and one 'Release' and I just swapped around the names whenever I deployed).</p>
  
  <p>Now I just noticed that it should be possible to let this happen automatically via the <a href="http://msdn.microsoft.com/en-us/library/dd465326(VS.100).aspx" rel="nofollow noreferrer">Web.config Transformation Syntax</a> where you put the modified connection string in the Web.Release.config version and it should then use that when the DLL is built under Release configuration.</p>
  
  <p>However it does not seem to work for me... </p>
  
  <p>Here is the relevant part of my regular Web.config file (which holds the Debug connection string for local usage):</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
    &lt;connectionStrings&gt;
      &lt;!-- Debug connection string. Release connection string is in Web.Release.config file --&gt;
      &lt;add name="DatabaseEntities" connectionString="A" providerName="System.Data.EntityClient" /&gt;
    &lt;/connectionStrings&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Here is the Web.Release.config file, which according to the examples should replace the 'DatabaseEntities' connection string "A" with "B" if the DLL is under Release mode:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"&gt;
  
    &lt;!-- Replace the DatabaseEntities connection string with the Release version (local IP address) --&gt;
    &lt;connectionStrings&gt;
      &lt;add name="DatabaseEntities"
        connectionString="B"
        xdt:Transform="Replace" xdt:Locator="Match(name)"/&gt;
    &lt;/connectionStrings&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>(Obviously "A" and "B" are just place-holders for my real connection strings)</p>
  
  <p>When I debug the application (e.g. just press F5) the default Web.config is used and I can access the database. I then change the build configuration to Release via the Configuration Manager. All the projects in the solution are set to Release configuration. Then I Build the solution (just via Build or even via a complete rebuild (e.g. Clean, Rebuild)). I upload the newly built DLLs to the webserver, as well as the Web.config and Web.Release.config files, and when I try to access the database I am unable, it is still trying to access the database via the debug IP address and hence cannot find it...</p>
  
  <p>It seems the Web.Release.config file is completely ignored, or at least the connection string is not being replaced. </p>
  
  <p>What am I doing wrong? Is the transformation syntax wrong? Am I not building the application under Release mode correctly? </p>