我正在测试EF core 2.0
预览。但是,当我尝试使用DbContext
获取EF core 1.1.2
的新实例时,OnConfiguring
方法不会被调用:
public class DatabaseContext : DbContext
{
DatabasesType database_type;
string URI;
public DbSet<User> user;
public DatabaseContext(DatabasesType database_type, string URI) : base()
{
this.database_type = database_type;
this.URI = URI;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
switch (database_type)
{
case DatabasesType.MySQL:
optionsBuilder.UseMySql(URI); break;
case DatabasesType.SQLite:
optionsBuilder.UseSqlite(URI); break;
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// ...
}
}
发生了什么事?有类似错误的人?
谢谢!