Getting "Operation is not valid for transaction status.", But I am not using a transaction

Stack Trace:    at System.Transactions.TransactionState.EnlistPromotableSinglePhase(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Transaction atomicTransaction)
  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.SqlInternalConnectionTds.Activate(Transaction transaction)
  at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
  at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
  at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
  at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
  at System.Data.SqlClient.SqlConnection.Open()
  at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
  at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
  at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
  at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
  at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
  at System.Linq.Queryable.All[TSource](IQueryable`1 source, Expression`1 predicate)

I do not use transaction or TransactionScopeat this stage. Is a transaction created automatically using the framework if it does not exist or the transaction is hiding from somewhere?

This is C # .NET 4, a query on MS SQL 2008 using LINQ-to-SQL.

+3
source share
2 answers

LINQ to SQL creates a transaction when you do SaveChanges so that the commit is atomic — that is, either all changes are saved or missing.

+2
source

While the alternative answer, I did not want to expand, as I just experienced this problem with my own application.

ASP.Net, .Net 4.0, , , SqlConnection.Open() . , 20+ , , , . OP.

, , , ASP.Net, , , Finalizer. , , , , Finalizer . , , Finalzer . , , Finalizer, ( , ).

, , - , WinDbg, :)

+1

All Articles