I can see that Web.config
file contains two files:
-web.Debug.config
-web.Release.config
Inside this config files there is the following comment:
In the example below, the "SetAttributes" transform will change the value of "connectionString" to use "ReleaseSQLServer" only when the "Match" locator finds an atrribute "name" that has a value of "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 the "Match" locator
?
I already have a connection String in Web.config
So how do I set this up?
should the main web.config file contain the production connection string or the other way around?
I'm looking for adivices from people that have done similar things
We are using xdt:Transform="Replace" which basically replaces the connection string of our development DB and it works perfectly. See below:
Development connection string (in your case web.Debug.config):
<connectionStrings>
<add name="MyDB" connectionString="Data Source=DebugSQLServer;Initial Catalog=MyDebugDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
Production connection string (in your case 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With