SQL
0
Вклад в тег
public partial class MainDataModel : DbContext
{
public MainDataModel()
: base("name=MainDataModel")
{
}
...
public MainDataModel(string databaseName)
{
Database.Connection.ConnectionString = @"Data Source=MySQLServer;Initial Catalog=" + databaseName + ";Integrated Security=True";
}
using (var context = new MainDataModel("MyFirstDatabase"))
{
...
}
using (var context = new MainDataModel("MySecondDatabase"))
{
...
}