Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Live vs Development connection strings [duplicate]

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

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

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

Is there an easy way to prevent us from having to change the connection string every time we want to upload to test or live?

We use team foundation server, I have no idea how to set up a build server or build definitions so looking for something simple if there is anything.

like image 236
James Wilson Avatar asked Jul 29 '13 16:07

James Wilson


People also ask

How do I find the ConnectionString in SQL Server?

Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.

What is ConnectionString in web config?

<connectionStrings> <add name="dbconnection" connectionString="Data Source=Soumalya;Integrated Security=true;Initial Catalog=MySampleDB" providerName="System. Data. SqlClient" />


1 Answers

If you're developing an ASP.NET application you can use web.config transforms to easily specify what will be different between each environment. The build process will generate an appropriate web.config for whatever environment you're targeting.

If you're building a desktop application, I'd look into Slow Cheetah which allows you to use the same web.config transform feature on any xml file you like, including an app.config. We've used this on a number of the projects at my company to streamline the deployment process between our various environments.

like image 110
p.s.w.g Avatar answered Sep 27 '22 16:09

p.s.w.g