文章出處

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());
    }
}

文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()