EntityFramework.Extended 支持 MySql

EntityFramework.Extended 默认不支持 MySql,需要配置如下代码:

[DbConfigurationType(typeof(DbContextConfiguration))]    //增加配置
public class SchoolDbContext : DbContext, IDbContext
{
    public SchoolDbContext()
        : base("name=db_connection")
    {
        Database.SetInitializer<SchoolDbContext>(null);
    }

    public DbSet<Student> Students { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.HasDefaultSchema("");    //增加配置
        modelBuilder.Configurations.Add(new StudentMap());
    }
}

public class DbContextConfiguration : DbConfiguration
{
    public DbContextConfiguration()
    {
        //增加配置
        EntityFramework.Locator.Current.Register<EntityFramework.Batch.IBatchRunner>(() => new MySqlBatchRunner());
    }
}



你可能感兴趣的:(EntityFramework.Extended 支持 MySql)