EntityFramework will not allow you to change database, so if you want to change the database at any point of time, you have to use the underlying StoreProvider's Changedatabse method, the extension method looks like :
public static void ChangeDatabase(this ObjectContext context, string databaseName)
{
DbConnection connection =((EntityConnection)context.Connection).StoreConnection;
if(connection.State != ConnectionState.Open)
{
connection.Open();
}
connection.ChangeDatabase(databaseName);
}
Please Like and Share the Blog, if you find it interesting and helpful.
public static void ChangeDatabase(this ObjectContext context, string databaseName)
{
DbConnection connection =((EntityConnection)context.Connection).StoreConnection;
if(connection.State != ConnectionState.Open)
{
connection.Open();
}
connection.ChangeDatabase(databaseName);
}
Please Like and Share the Blog, if you find it interesting and helpful.
No comments:
Post a Comment