Ostateczne rozwiązanie to:
-
Stwórz własnego następcę DbConfiguration z blackjackiem i prostytutkami:
public class MultipleDbConfiguration : DbConfiguration { #region Constructors public MultipleDbConfiguration() { SetProviderServices(MySqlProviderInvariantName.ProviderName, new MySqlProviderServices()); } #endregion Constructors #region Public methods public static DbConnection GetMySqlConnection(string connectionString) { var connectionFactory = new MySqlConnectionFactory(); return connectionFactory.CreateConnection(connectionString); } #endregion Public methods }
-
Oznacz Ms_SqlContext za pomocą MultipleDbConfiguration (i nie rób nic więcej z tego rodzaju DbContext)
[DbConfigurationType(typeof(MultipleDbConfiguration))] partial class Ms_SqlContext { }
-
Oznacz Ms_SqlContext za pomocą MultipleDbConfiguration i dopasuj MY_SqlContext(string nameOrConnectionString) za pomocą wywołania MultipleDbConfiguration.GetMySqlConnection(nameOrConnectionString)
[DbConfigurationType(typeof(MultipleDbConfiguration))] partial class MY_SqlContext : DbContext { public MY_SqlContext(string nameOrConnectionString) : base(MultipleDbConfiguration.GetMySqlConnection(nameOrConnectionString), true) {} }
-
TO JEST!!!