How to change the connection string when publishing a project?

I see that the file Web.configcontains two files:

-web.Debug.config
-web.Release.config

Inside these configuration files there is the following comment:

In the example below, the SetAttributes transformation will only change the connectionString value to use ReleaseSQLServer when the Match Locator finds the atrribute attribute name, which has the value MyDB.

<connectionStrings>
  <add name="MyDB" 
    connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>

What is "Match" locator? I already have a String connection in. Web.configSo, how do I configure this? should the main web.config file contain a production connection string or vice versa? I am looking for ads from people who have done similar things.

+4
2

xdt: Transform = "Replace", . . :

( web.Debug.config):

<connectionStrings>
  <add name="MyDB" connectionString="Data Source=DebugSQLServer;Initial Catalog=MyDebugDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

( web.Release.config):

<connectionStrings xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="Replace" xdt:Locator="Match(name)" />
</connectionStrings>
+6

Match(name) , connectionString MyDB, , web.config, connectionString , web.debug.config connectionString -. MSDN. , , .

0

All Articles