直接InsertRange空集合会报错,如果我们是同时执行多个添加或修改,不要共用一个上下文,最好是在方法里面声明上下文进行区分,不然容易报错
//如果同时执行多个添加,更新 操作不要共用一个上下文,使用局部上下文进行区分,不然报错
//private static DbContext dbContext = new DbContext();
if (addList.Count>0) { dbContext.FsFactories.InsertRange(addList); } if (updateList.Count>0) { dbContext.FsFactories.UpdateRange(updateList); }