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.
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.
<connectionStrings> <add name="dbconnection" connectionString="Data Source=Soumalya;Integrated Security=true;Initial Catalog=MySampleDB" providerName="System. Data. SqlClient" />
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With