• The requested operation cannot be completed because the connection has been broken


    具体报错

    The requested operation cannot be completed because the connection has been broken. -- xxxForyyy->Index at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
    at System.Data.SqlClient.SqlDelegatedTransaction.Initialize()
    at System.Transactions.TransactionStatePSPEOperation.PSPEInitialize(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Guid promoterType)
    at System.Transactions.TransactionStateActive.EnlistPromotableSinglePhase(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Transaction atomicTransaction, Guid promoterType)
    at System.Transactions.Transaction.EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Guid promoterType)
    at System.Transactions.Transaction.EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
    at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
    at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
    at System.Data.SqlClient.SqlInternalConnection.EnlistTransaction(Transaction transaction)
    at System.Data.SqlClient.SqlConnection.EnlistTransaction(Transaction transaction)
    at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<EnlistTransaction>b__30(DbConnection t, EnlistTransactionInterceptionContext c)
    at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
    at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.EnlistTransaction(DbConnection connection, EnlistTransactionInterceptionContext interceptionContext)
    at System.Data.Entity.Core.EntityClient.EntityConnection.EnlistTransaction(Transaction transaction)

    错误:正在创建模型,此时不可使用上下文。如果在 OnModelCreating 方法内使用上下文或如果多个线程同时访问同一上下文实例,可能引发此异常。请注意不保证 DbContext 的实例成员和相关类是线程安全的。

    -------------------------

    原因可能是并发多线程调用DbContext问题,可以将报错点(Action,AttributeFilter)中的 DbContext 调用换成原生的SqlConnection 试下。

  • 相关阅读:
    中国正在消失的老行当
    ie9 scrollbar中hover 高度增高的bug
    (替月光博客备份)百度百科:游荡在中国的窃贼
    严格模式下 W3C Strict 验证的几个注意事项
    [转]滤镜渐变使用 IE浏览器
    1.什么是串口?
    6.串口操作之API篇 GetCommTimeouts SetCommTimeouts
    5.串口操作之API篇 SetupComm GetCommState SetCommState
    TeeChart经验总结 13.Export之2.对象保存
    解决"手机存储暂不能使用""SIM卡存储暂不能使用"
  • 原文地址:https://www.cnblogs.com/runliuv/p/12915714.html
Copyright © 2020-2023  润新知