You are usually better off to pass the connection string explicitly. You can generate your various connection strings in global.asax or store them in a configuration file. The snippet below generates a connection string using integrated security and one using SQL security (each string could easily resolve to different DBs).
string conStrIntegratedSecurity = new System.Data.EntityClient.EntityConnectionStringBuilder
{
Metadata = "res://*/LT08.csdl|res://*/LT08.ssdl|res://*/LT08.msl",
Provider = "System.Data.SqlClient",
ProviderConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder
{
InitialCatalog = "AdventureWorksLT2008",
DataSource = "bing0",
IntegratedSecurity = true,
}.ConnectionString
}.ConnectionString;
string connectionString = new System.Data.EntityClient.EntityConnectionStringBuilder
{
Metadata = "res://*/LT08.csdl|res://*/LT08.ssdl|res://*/LT08.msl",
Provider = "System.Data.SqlClient",
ProviderConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder
{
InitialCatalog = "AdventureWorksLT2008",
DataSource = "bing0",
IntegratedSecurity = false,
UserID = getUID(), // User ID such as "sa"
Password= getPWD(), // hide the password
}.ConnectionString
}.ConnectionString;
Now just pass in the conections string you want
string conStr = connectionString ;
//conStr = "Data Source=ricka0;Initial Catalog=AdventureWorksLT;"
// + "Persist Security Info=True;User ID=sa;Password=*(IU89iu;";
model.RegisterContext(() => new DataClassesDataContext(conStr), new ContextConfiguration() {
ScaffoldAllTables = true });