asp.net 2.0 introduced a new section in the web.config file -ConnectionStrings. This new configuration section allows you to add connection strings in your web.config, like we always have, or in a different data source.
In Subtext 2.0 we're using this new feature to split the connection string out into a new configuration file, user.config. Doing this should make day to day development easier for our development team by reducing the number of merge conflicts in web.config. Since most every developer has a different database configuration, it makes sense to keep this information in its own file and away from the other more static configuration settings.
Show me how!
I'm a visual type of guy and typically get more out of a demo or code sample than from some author's rambling writing...
Subtext's web.config
<configuration>
...
<connectionStrings configSource="user.config">
<!-- you can still add connection strings here -->
</connectionStrings>
...
As John pointed out in the comments, when using a configSource you must move all values under the configuration section into the external file. Which is why I've crossed out the comment in the above code sample.
The user.config
<connectionStrings>
<add name="subtextData"
connectionString="Server=.;Database=myData;Trusted_Connection=True;" />
</connectionStrings>
Then each developer modifies their user.config file for their setup. No more merging nor conflict issues with that sucker in web.config.
I realize you could still run into some issues where another developer accidentally checks in their user.config and then SVN tries to merge the changes into your file. But since the only thing in that file is the connection string settings, you can just revert the other developer's changes without the worry of losing other, intended, changes.
Connection string resources
In the above code you might have noticed that I set my Server equal to . (dot). I believe that is just shorthand for localhost, but I don't remember where I picked that up. Does anyone out there know?
In trying to find out where I first learned that syntax, I used the following resources that might help you get your connection string just right: