Connection Strings for Live vs Development

We have a development database and a production database. What I'm trying to prevent is to change:

connectionString="Data Source=server;Initial Catalog=test; connectionString="Data Source=server;Initial Catalog=live; 

We have two places where we deploy the site. One for testing and one live.

Is there an easy way to stop us from changing the connection string every time we want to download or test?

We are using the team foundation server, I have no idea how to set up the build server or create definitions, so you are looking for something simple, if there is something.

+7
c # visual-studio-2010 connection-string
source share
3 answers

If you are developing an ASP.NET application, you can use web.config transforms to easily determine what will differ between each environment. The build process will create the right web.config for any environment you are targeting.

If you are building a desktop application, I would consider Slow Cheetah , which allows you to use the same function to convert web.config to any XML file that you like, including app.config . We used this in a number of projects at my company to optimize the deployment process between our different environments.

+6
source share

You can use web.config.release to mention your release mode configurations. They are part of VS2010 and above. You can take a very good look at the Scott Hanselman article here .

It should be noted that the transition from debugging to release will occur whenever you publish your web site before deploying .

+3
source share

Find a good tutorial on building a continuous integration assembly. Newer versions of TFS do a great job of this.

This must be dealt with, but it is worth the effort. Try the MSDN articles for it, go for all the default options, and that won't be so bad.

Get CI and run, and you will know what to do with these web.config conversions (which will solve your immediate problem). But by going through the build setup process, you will find deployments a lot easier.

+1
source share

All Articles