尝试使用 Entity Framework 在循环中执行插入存储过程,如下所示:
var context = new Entities()
var items = context.GetAllItems().ToList();
foreach(var item in items)
{
// Other select and update procedures
context.InsertProcedure(item.Prop1);
}
context.SaveChanges();
但我遇到了异常。
New transaction is not allowed because there are other threads running in the session
有人以前有过这个吗?
最佳答案
原来还有一个异常,但是看起来这个异常总是在循环出现问题时抛出。
我所做的是在模型浏览器中将存储过程的返回类型更改为无
关于c# - Entity Framework 在循环中插入存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40984421/