The web.config conversions that are part of Visual Studio 2010 use XSLT to "convert" the current web.config file to its .Debug or .Release version.
In your .Debug / .Release files, you need to add the following parameter to the fields of the connection string:
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"
This will cause each line of the connection string to find the corresponding name and update the attributes accordingly.
Note. You do not have to worry about updating the providerName parameter in the conversion files, since they do not change.
Here is an example from one of my applications. Here is the section of the web.config file:
<connectionStrings> <add name="EAF" connectionString="Data Source=NTSQLT\S2K5TST;Initial Catalog=HR;User ID=EAFApp;Password=XXXX" providerName="System.Data.SqlClient" /> </connectionString>
And here the web.config.release section does the correct conversion:
<connectionStrings> <add name="EAF" connectionString="Data Source=NTSQLP\S2K5TST;Initial Catalog=HR;User ID=EAFApp;Password=YYYY" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" /> </connectionStrings>
One added note: Conversions occur only when the site is published, and not when it is simple with F5 or CTRL + F5. If you need to run the update with the given config locally, you will have to manually modify the Web.config file for this.
For more information, you can see the MSDN documentation.
https://msdn.microsoft.com/en-us/library/dd465326(VS.100).aspx
Dillie-O Apr 27 '11 at 10:29 2011-04-27 22:29
source share