ConnectionString different for different builds

7

I have two connection string, one when I'm developing that uses my local bank and another for when I deploy the application in Azure.

I want the application to know which one to use depending on the type of build I do. What is the simplest way to do this?

Do you want to do the connection string level or would I need two different Web.config?

    
asked by anonymous 13.08.2015 / 22:58

1 answer

8

The procedure is very similar to this answer here , only to <connectionstrings> . For example:

Web.Release.config

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <connectionStrings>
      <add name="DefaultConnection"
        connectionString="MinhaConnectionStringDeProdução"
        xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>
</configuration>

Web.Debug.config

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <connectionStrings>
      <add name="DefaultConnection"
        connectionString="MinhaConnectionStringDeDebug"
        xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>
</configuration>
    
13.08.2015 / 23:02