Fork me on GitHub

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());
    }
}
posted @ 2016-08-03 15:14  田园里的蟋蟀  阅读(1932)  评论(5编辑  收藏  举报