I have two entity structure contexts, one for MySql and one for sql. If I run the application, I get the following error:
The default DbConfiguration instance was used by the Entity Framework before the 'MySqlEFConfiguration' type was discovered.
However, if I found the database type when the application started, indicating to it Database.SetInitializer<MySqlContext>, my normal sql context now tries to connect using the mysql provider.
My mysql context
[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class ZipCodeContext : DbContext
{
public DbSet<ZipCode> ZipCodes { get; set; }
}
My normal context
public class MyContext : DbContext
{
public DbSet<MyClass> MyClasses{get;set;}
}
and finally, my web configuration for the entity structure section
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
I hope this is clear enough, I knock my head on the table
source
share