I have a generic code where we execute passed lambda on the DbContext. DbContext can be either postgres and mongo. For postgres we had to use `CreateExecutionStrategy().ExecuteInTransaction` pattern. It seems to work correctly on mongo as well, but under the hood we always have an exception like this:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Can not Dispose MongoTransaction cbf3f23f-ead8-4c52-ad3d-9c5abb3485ff because it is Active.
at MongoDB.EntityFrameworkCore.Storage.MongoTransaction.AssertCorrectState(String action, TransactionState[] validStates)
at MongoDB.EntityFrameworkCore.Storage.MongoTransaction.DisposeAsync()
at System.Runtime.CompilerServices.ConfiguredAsyncDisposable.DisposeAsync()
at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass24_0`2.<<ExecuteInTransactionAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
Creating transaction object directly works without this exception, it only throws when using the execution strategy.
I think this is not really that critical since the rollback itself seems to work correctly, but the exception can brake some flows that assume proper support for this execution strategy