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 @   田园里的蟋蟀  阅读(1935)  评论(5)    收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示