zoukankan      html  css  js  c++  java
  • 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 试下。

  • 相关阅读:
    Oracle数据库学习_唯一性索引(Unique Index)与普通索引(Normal Index)
    Oracle数据库学习笔记_oracle创建表索引index
    Oracle数据库学习笔记_oracle之exist 语句
    Oracle数据库学习笔记_Oracle之replace()函数的使用
    Oracle数据库学习笔记_trim( )、ltrim( )、rtrim( )三个函数的用法
    Oracle数据库学习笔记_Oracle的PLS_INTEGER类型
    SQL教程_SQL语法、过程和函数概述
    Oracle数据库学习_Oracle监听配置和网络服务名配置的三种方法
    Oracle数据库学习_Oracle监听程序LISTENER和网络服务名Tnsname
    Oracle数据库学习_Windows系统查看Oracle数据库监听状态的方法
  • 原文地址:https://www.cnblogs.com/runliuv/p/12915714.html
Copyright © 2011-2022 走看看