Update the connection string dynamically.
using System.Data.SqlClient;
using System.Data.EntityClient;
public virtual string UpdateConnectionString(string database)
{
var _connectionString = "Data Source=.;Initial Catalog=SampleDB;Integrated Security=SSPI;MultipleActiveResultSets=True"
var sqlBuilder = new SqlConnectionStringBuilder(_connectionString);
sqlBuilder.InitialCatalog = database.ToString();
return sqlBuilder.ConnectionString;
}
Change Entity Framework ConnectionString dynamically
public virtual string UpdateEFConnectionString(string newConnectionString)
{
var csBuilder = new EntityConnectionStringBuilder();
csBuilder.ProviderConnectionString = newConnectionString;
return csBuilder.ConnectionString;
}
Thanks for sharing excellent information. Your
ReplyDeletewebsite is very cool.
Premium
Premium