对以下错误有任何想法:
System.Data.EntityException: An error occurred while starting a transaction on the provider connection. See the inner exception for details. ---> System.ObjectDisposedException: Safe handle has been closed
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
at SNINativeMethodWrapper.SNIPacketReset(SafeHandle pConn, IOType ioType, SafeHandle packet)
at System.Data.SqlClient.TdsParserStateObject.WriteSni()
at System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)
at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
at System.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName)
at System.Data.SqlClient.SqlInternalConnection.BeginTransaction(IsolationLevel iso)
at System.Data.SqlClient.SqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at System.Data.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)
--- End of inner exception stack trace ---
at System.Data.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at System.Data.EntityClient.EntityConnection.BeginTransaction()
at System.Data.Objects.ObjectContext.SaveChanges(Boolean acceptChangesDuringSave)
为了给你一点背景知识,我们在应用程序的这一部分使用了纯ADO.NET(没有事务),运行正常。切换到EF后,开始出现此错误。我不认为这与EF有关,因为它在ADO.NET事务代码中发生了很深的变化。有没有办法在EF中禁用交易?
答案 0 :(得分:0)
在做了一些研究并查看反汇编的代码之后,我发现你无法在EF中禁用事务。