Thanks in advance.
I'm using VS 2010 with a Razor project and I'd like to use a transformation to change the DB connection string to a debug version when I'm debugging. I'm not connecting to the production DB in debug mode, I'm using a local copy. I've tried this...
When I start debugging, the connection does not change. I've tried Replace instead of SetAttributes, and I also tried deleting the files and using "Add config transformations" to regenerate the file from scratch.
Is this supposed to work in this way, or is this feature meant to only work on publish? If so, what's the best practice for what I want to do?
aspnet100
0 Points
5 Posts
Trying to use xdt:Transform in Web.Debug.config
Apr 07, 2012 08:18 AM|LINK
Thanks in advance.
I'm using VS 2010 with a Razor project and I'd like to use a transformation to change the DB connection string to a debug version when I'm debugging. I'm not connecting to the production DB in debug mode, I'm using a local copy. I've tried this...
Web.config:
<connectionStrings>
<add name="DB"
connectionString="Data Source=machine;Initial Catalog=DBname;User ID=sa;Password=pass"
providerName="System.Data.SqlClient" />
...
Web.Debug.config:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="DB"
connectionString="Data Source=machine;Initial Catalog=DBname;User ID=sa;Password=pass"
providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes(connectionString)"
xdt:Locator="Match(name)"/>
...
When I start debugging, the connection does not change. I've tried Replace instead of SetAttributes, and I also tried deleting the files and using "Add config transformations" to regenerate the file from scratch.
Is this supposed to work in this way, or is this feature meant to only work on publish? If so, what's the best practice for what I want to do?
aspnet100
0 Points
5 Posts
Re: Trying to use xdt:Transform in Web.Debug.config
Apr 09, 2012 04:21 AM|LINK
It works fine if you publish. The "Replace" option will change the values based on whether you publish in Debug or Release mode.