EntityFramework.Extended MYSQL 报异常处理方法
最近使用EntityFramework.Extended 操作MYSQL数据库的时候,马蛋发现都有问题,网上找了好久没有找到解决方案,最后只能扩展写了一个通过SQL操作数据库的方法,但是感觉这样操作还是不完美,经过各方面收集资料,终于找到了问题的处理方法:
public class myContent : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("");
base.OnModelCreating(modelBuilder);
EntityFramework.Locator.Current.Register<EntityFramework.Batch.IBatchRunner>(() => new MySqlBatchRunner()); }// ......
}
网友提供的处理方法:
public class myContent : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("");
base.OnModelCreating(modelBuilder);
}
// ......
}
[STAThread]
static void Main()
{
EntityFramework.Container container = new EntityFramework.Container();
EntityFramework.Locator.RegisterDefaults(container);
container.Register<EntityFramework.Batch.IBatchRunner>(() => new EntityFramework.Batch.MySqlBatchRunner());
EntityFramework.Locator.SetContainer(container);
......
}
网友回复的处理方案:
public class DbContextConfiguration : DbConfiguration
{
public DbContextConfiguration()
{
EntityFramework.Locator.Current.Register<EntityFramework.Batch.IBatchRunner>(() => new MySqlBatchRunner());
}
}

浙公网安备 33010602011771号