Search code examples
sql-serverdatabasestringconnection

Is there any way to connect database with visual studio that connection string may not be changed at the time of deployment


When I connect I have already my localhost connection string. I want to know that is there any way that I connect database to visual studio but i don't have to change connection string all the time during deployment.


Solution

  • Simply you can use transform file to do this. In your Solution Explore expand your Web.config file then you will see there are 2 files as

    Web.Debug.config 
    Web.Release.config
    

    put your development configurations and connection string in Web.Debug.config and Deployment related configurations and connection string in to Web.Release.config

    then it automatically pick the config file based on your build