Description
Description:
While testing the application with simulated latency using Clumsy (to introduce artificial delays between the app and the database), I frequently encounter the following EF Core exception:
A second operation was started on this context instance before a previous operation completed.
This appears to occur when multiple asynchronous operations are triggered close together, resulting in overlapping usage of the same scoped DbContext.
The error can also occur during rapid component navigation, when an unfinished async database operation is still in progress while a new one begins, both sharing the same scoped DbContext instance.
Question:
Would using IDbContextFactory or DbContextFactory in the handlers be a better and safer long-term approach to prevent this issue—especially under high-latency or concurrent query scenarios?