I think the best way to do this is by combining the answers of Albin and Rup. Make a difference in the configuration file, and then read it at runtime and feed it to the context constructor, something like this:
Web.config:
<appSettings>
<add key="ConString" Value="The connection string" />
CODE:
var DBConnString = System.Configuration.ConfigurationManager.AppSettings("ConString");
var dataContext= new MyDataContext(sDBConnString)
this way you can change the connection string even at runtime, and it will work and change in the current program.
source
share