You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class DistributedTransaction{
OracleDbContext _oracleDbContext;
MsSqlDbContext _msSqlDbContext;
public DistributedTransaction(OracleDbContext oracleDbContext, MsSqlDbContext msSqlDbContext)
{
_oracleDbContext = oracleDbContext;
_msSqlDbContext = msSqlDbContext;
}
public async Task ExecuteAsync(){
using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
try {
//Do some Inserts updates
//Do some Inserts updates
//Do some Inserts updates
await _oracleDbContext.SaveChangesAsync(); //This works fine
await _msSqlDbContext.SaveChangesAsync() ; //Gets Null reference here
scope.Complete();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Transactions.TransactionStateAborted.EnterState(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.ConvertToOletxTransaction(Transaction transaction)
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.ProviderBase.DbConnectionPool.PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, Transaction transaction)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, 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.TryOpenConnectionInt
Include provider and version information
EF Core version: 8.0.2
Database provider: MSSQL, Oracle
Target framework: DOTNET CORE 8
Operating system: WINDOWS 10
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered:
This looks like an issue in System.Transactions rather than in EF.
Can you confirm whether this happens consistently, or only occasionally? Are you able to reproduce the same thing with two SQL Server connections rather than Oracle and SQL Server?
It happens consistently.
I did not try with two SQL server connection, but tried with just one.. And it worked fine.
I will try out two different connections and will post how it goes here
Include provider and version information
EF Core version: 8.0.2
Database provider: MSSQL, Oracle
Target framework: DOTNET CORE 8
Operating system: WINDOWS 10
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered: