diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs index a34be614cd..473d9cf629 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs @@ -159,6 +159,11 @@ override protected DbCommand CreateDbCommand() DbProviderFactory providerFactory = ConnectionFactory.ProviderFactory; command = providerFactory.CreateCommand(); command.Connection = this; + if (InnerConnection is SqlInternalConnection { CurrentTransaction: { Parent: {} transaction} }) + { + command.Transaction = transaction; + } + return command; } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs index 07d44f020c..5b8a0eafa0 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs @@ -205,6 +205,11 @@ override protected DbCommand CreateDbCommand() DbProviderFactory providerFactory = ConnectionFactory.ProviderFactory; DbCommand command = providerFactory.CreateCommand(); command.Connection = this; + if (InnerConnection is SqlInternalConnection { CurrentTransaction: { Parent: {} transaction} }) + { + command.Transaction = transaction; + } + return command; } }