Your settings for the Entity, I am rusty on Linq to SQL but think it is similar, are in the App.Config on the project where you CREATED you Linq to SQL model. They are similar to this(using Entity Model):
< connectionStrings>
< add name="Example" connectionString="metadata=res://*/ExampleDB.csdl|res://*/ExampleDB.ssdl|res://*/ExampleDB.msl;provider=System.Data.SqlClient;provider connection string="data source=ACTUALSERVER;initial catalog=ACTUALDATABASE;persist security info=True;user id=(SET USER HERE);password=(SET PASSWORD HERE);multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
< /connectionStrings>
The important part for connection is the connection string though:
"data source=ACTUALSERVER;initial catalog=ACTUALDATABASE;persist security info=True;user id=(SET USER HERE);password=(SET PASSWORD HERE);
You can try to alter this to different connection strings if you want, and keeping the metadata the same. For differenent environments like "Dev", "QA", "UAT", "PROD" etc... And then copy and paste the connection block starting with the '< add name="' and till the end portion of 'providerName='(thing)' />. Then just alter the connection string and give it a different name. Then you could have the calling code use a different context or connection like:
using(MyContext context = new MyContext())
{
context.Connection = (new connection)
(your data return method)
}
You may be able to do this directly in the constructor of your context(MyContext). Cannot recall. Generally I usually set up multiple configs "DEV", "QA", "UAT", "PROD" and have them build for different environments for a service. You can build a connection string manually but dynamic connection strings can be a pain as you as a developer now need to ensure a few things:
- The model of a Dev environment EXACTLY matches another with it's objects in your model. If not goodbye code return.
- If you are invoking a set user that you are ensuring that your user has rights on certain environments
- That you are not putting the integrity of your code at risk by showing too much publicly for user settings.