И така, окончателното решение е:
-
Създайте собствен наследник на DbConfiguration с блекджек и проститутки:
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 }
-
Маркирайте Ms_SqlContext с MultipleDbConfiguration (и не правете нищо друго с този вид DbContext)
[DbConfigurationType(typeof(MultipleDbConfiguration))] partial class Ms_SqlContext { }
-
Маркирайте Ms_SqlContext с MultipleDbConfiguration и коригирайте MY_SqlContext(string nameOrConnectionString) с извикване MultipleDbConfiguration.GetMySqlConnection(nameOrConnectionString)
[DbConfigurationType(typeof(MultipleDbConfiguration))] partial class MY_SqlContext : DbContext { public MY_SqlContext(string nameOrConnectionString) : base(MultipleDbConfiguration.GetMySqlConnection(nameOrConnectionString), true) {} }
-
ТОВА Е!!!