I have three database environments, Developer, Testing and Production. To setup database with sample data i created a console app where user selects environment to setup the database. I am using Entity Framework database first but stuck with how to select instance at run time. There is only one database model is it possible to change db connection at run time?
i used following code and it throws exception.
// Truncate all Data
if (env.Key == ConsoleKey.D)
{
db.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["db_dev"].ToString();
}
Model Entities has no constructor to get Connection String..