EF Core: A second operation was started on this context instance before a previous operation completed
The same DbContext was used concurrently — async calls not awaited, parallel tasks sharing a context, or a context registered as singleton.
Seen on:
.NET
Meaning
DbContext isn’t thread-safe. Missing await, Task.WhenAll over queries on one context, or injecting a scoped context into a singleton/background service cause it.
Common causes
- Missing await on an async EF call
- Parallel queries (Task.WhenAll) on one context
- DbContext captured by a singleton/hosted service
- Blazor Server components sharing a context
⚡ Quick fix
- Await every EF call
- Use separate contexts (IDbContextFactory) for parallel work
- Create scopes in background services
Detailed fix by platform
C#
- csharp
public class Worker(IDbContextFactory<AppDb> factory) { public async Task RunAsync() { await using var db = await factory.CreateDbContextAsync(); /* ... */ } }
How to diagnose
- Await — All async calls awaited?
- Lifetime — Context lifetime vs consumer
- Parallel — WhenAll on one context?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in .NET
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026