Skip to content

EF and EFCore in shared transaction regression with EFCore nuget v10 #37388

Closed as duplicate

Description

@ladeak

Bug description

I use Entiry Framework and EntityFramework Core at the same time in my project with Azure SQL and SQL Server 2025.

Queries implemented using EF6 and using EFCore participate in a single transaction. Transactions are created and managed with the TransactionScope

Both libraries use Microsoft.Data.SqlClient version 6.1.3 and .NET 10.

When I update EntiryFrameworkCore nuget package from version 9.0.10 to 10.0.1 I get the following Exception when an entity framework query is executed with a transaction that also executes EF Core. The exception is thrown when EF tries to open a DB connection after an EFCore query was executed (I have not tested the other way around yet).

Implicit distributed transactions have not been enabled. If you're intentionally starting a distributed transaction, set TransactionManager.ImplicitDistributedTransactions to true.

Your code

<work in progress>

Stack traces

StackTrace of the inner exception:

   at System.Transactions.DtcProxyShim.DtcProxyShimFactory.ConnectToProxy(String nodeName, Guid resourceManagerIdentifier, Object managedIdentifier, Boolean& nodeNameMatches, Byte[]& whereabouts, ResourceManagerShim& resourceManagerShim)
   at System.Transactions.Oletx.DtcTransactionManager.Initialize()
   at System.Transactions.Oletx.DtcTransactionManager.get_ProxyShimFactory()
   at System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropagationToken(Byte[] propagationToken)
   at System.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransaction tx)
   at System.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransaction tx)
   at System.Transactions.EnlistableStates.Promote(InternalTransaction tx)
   at System.Transactions.Transaction.Promote()
   at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
   at Microsoft.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts)
   at Microsoft.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
   at Microsoft.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
   at Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool.PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, Transaction transaction)
   at Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 taskCompletionSource, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open()
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<>c.<Open>b__13_0(DbConnection t, DbConnectionInterceptionContext 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.Open(DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Core.EntityClient.EntityConnection.<Open>b__55_0()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass2_0.<Execute>b__0() in /_/src/ErikEJ.EntityFramework.SqlServer/DefaultSqlExecutionStrategy.cs:line 32
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation) in /_/src/ErikEJ.EntityFramework.SqlServer/DefaultSqlExecutionStrategy.cs:line 43
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) in /_/src/ErikEJ.EntityFramework.SqlServer/DefaultSqlExecutionStrategy.cs:line 29
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()

StackTrace of the Outer Exception

   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass41_0.<GetResults>b__0()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation) in /_/src/ErikEJ.EntityFramework.SqlServer/DefaultSqlExecutionStrategy.cs:line 43
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__31_0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Linq.Enumerable.IEnumerableSelectIterator`2.ToList()

EF Core version

10.0.1

Database provider

Microsoft.Data.SqlClient

Target framework

.NET 10

Operating system

Windows 11 and Linux

IDE

Visual Studio 2026

Activity

  1. changed the title [-]EF and EFCore in one transaction regression[/-] [+]EF and EFCore in shared transaction regression[/+] on Dec 16, 2025
  2. MihuBot commented on Dec 16, 2025

    @MihuBot
  3. ladeak commented on Dec 16, 2025

    @ladeak
    Author

    Before further investigation, let me test if adding Application Name resolves the issue as mentioned in the linked post

  4. changed the title [-]EF and EFCore in shared transaction regression[/-] [+]EF and EFCore in shared transaction regression with EFCore nuget v10[/+] on Dec 16, 2025
  5. roji commented on Dec 16, 2025

    @roji
    Member

    @ladeak yes, this seems like #36911. I'll go ahead and close as a duplicate, but post back here and I'll reopen if necessary.

  6. ladeak commented on Dec 18, 2025

    @ladeak
    Author

    The suggested solution works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions