De uiteindelijke oplossing is dus:
-
Maak een eigen DbConfiguration-opvolger met blackjack en hookers:
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 }
-
Markeer Ms_SqlContext met MultipleDbConfiguration (en doe niets anders met dat soort DbContext)
[DbConfigurationType(typeof(MultipleDbConfiguration))] partial class Ms_SqlContext { }
-
Markeer Ms_SqlContext met MultipleDbConfiguration, en pas MY_SqlContext(string nameOrConnectionString) aan met call MultipleDbConfiguration.GetMySqlConnection(nameOrConnectionString)
[DbConfigurationType(typeof(MultipleDbConfiguration))] partial class MY_SqlContext : DbContext { public MY_SqlContext(string nameOrConnectionString) : base(MultipleDbConfiguration.GetMySqlConnection(nameOrConnectionString), true) {} }
-
DAT IS HET!!!