We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Multiples notifications, one enqueue - New transaction is not allowed because there are other threads running in the session

Hello, we got a stranger error when send multiples notifications from one enqueue. “New transaction is not allowed because there are other threads running in the session”. We use .NetCore 3.1 with Entity Framework, the error occur when the second notification is called.

First of all we using CQRS as architecture, so, for this error we have a event for many event handlers called by single enqueue. The first notification occur normally, the context of entity framework works well, but when that notification ends and Hangfire goes to the next one, the context of entity was null and the error above occurs.

The context i mentioned above is Microsoft.EntityFrameworkCore.DbContext as default of entity, but for some reason, when the error occurs if i call …DbContext.Database.GetDbConnection() we can see the SQL Connection is opened but the …DbContext.Database.CurrentTransaction is null.

We use AddDbContextPool in Program/Startup of Hangfire project.

I don’t know whats goes wrong, if someone have some ideas.

Thanks in advance.