异常信息如下:
System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.InvalidOperationException: ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.
事务尚未初始化
没有用事务,只是一个查询
_sendNotificationRepository.GetMany(m => id2 == m.Id)
@老六代码: try catch一下
原因找到了,是因为同事在注入DbContext时,把DbContext声明为静态的了,并发时造成了线程不安全的DbContext的替换。在此提醒各位,请合理使用依赖注入。