C# System.lnvalidOperationException:"A second operation started on this context before a previousoperation completed. This is usually caused by different threads using the same instance ofDbContext...

与上一篇问题一样,只是错误不一样,DbContext 不支持并发请求,每个数据库操作都使用await就可以了。

但是实际操作中以上方法并没有解决问题,错误还是偶尔会出现,于是我又搜索了一些资料,找到一个应该是一样的问题,在这里把原帖发出来。

c# - Entity Framework Core: A second operation started on this context before a previous operation completed - Stack Overflow

但是还是没有解决我的问题,所以我不再使用DbContext了,而是改用直接写sql的方式去操作就可以了

posted @ 2023-04-10 11:30  峨嵋峰  阅读(165)  评论(0编辑  收藏  举报