<< back to blog

.NET Config for Multiple Developers

.net ~ nhibernate

30 Apr, 2009

Here’s a simple solution I just thought up for when you have multiple developers working on a project, and you want each to have their own connection string in Web.config (under source control).

I’ve seen some pretty complex approaches to this, but what about this one…

//Global.asax.cs

protected void Application_Start()
{	
    //other stuff here...

    UoW.Configure(
        WebConfigurationManager
           .ConnectionStrings[Environment.MachineName].ConnectionString);
}

Then, in web config, you’d have something like this.

//Web.config

<connectionStrings>		
    <add name="TOBIN-AB69C7A1F" connectionString="server=.\SQLEXPRESS2008;database=MdlDevelopment;Trusted_Connection=true"/>
    <add name="LIVESERVER-101" connectionString="data source=192.168.1.87;Integrated Security=SSPI;Trusted_Connection=true"/>
    <!-- add yours here -->

In short, each developer adds a new connection string to the Web.Config. The name is his machine name. Simple huh!

You may also like...
Automating .NET development (and NHibernate) with IronRuby + Rake
Get a Rails-Stylee Interactive Shell For Your NHibernate Backed Domain Model
In Memory SQLite Testing with NHibernate
NHibernate Trick
OSX MonoDevelop MVC?
NHibernate: Calling Update Unnecessarily
.NET Config for Multiple Developers
Rake and .NET: The Story Continues
NHibernate in Action 2nd Edition - Your Opinion
Shorthand Repository Accessors

kick it on DotNetKicks.com
blog comments powered by Disqus