I have a DbContext
:
[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class MyDbContext : DbContext
{
public DbSet<MyClass> MyClasses { get; set; }
}
Now, what if I want to be able to use another DbConfigurationType
, according to AppSettings value?
So that, I change AppSettings value from MySQL
to MSSQL
and it becomes:
[DbConfigurationType(typeof(MsSqlEFConfiguration))]
public class MyDbContext : DbContext
{
public DbSet<MyClass> MyClasses { get; set; }
}
Of course, I can create a factory, and use reflection to create a new class with custom attribute. However, is there a solution without reflection?
MySqlEFConfiguration
vsMsSqlEFConfiguration