您的位置:首页 > 数据库 > MySQL

EntityFramework.Extended 支持 MySql

2016-08-03 15:14 489 查看
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());
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐