{"id":85,"hash":"c191b35def74b14b35c6c919d76c7bb664bd78a1ac9d0f600fef0e1bd5743d7d","pattern":"System.InvalidOperationException: A second operation was started","full_message":"System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed","ecosystem":"nuget","package_name":"Microsoft.EntityFrameworkCore","package_version":null,"solution":"DbContext is not thread-safe; a parallel Task used the same instance.\n1. Register DbContext as Scoped (the default in ASP.NET Core) — one per request.\n2. For background work: inject `IDbContextFactory<TContext>` and `CreateDbContext()` per task.\n3. Don't pass DbContext through `Task.Run` or `Parallel.ForEach` unless you create a new scope inside.","confidence":0.92,"source":"ef-docs","source_url":"https://learn.microsoft.com/en-us/ef/core/dbcontext-configuration/","votes":18,"created_at":"2026-04-19T03:37:14.152632+00:00","updated_at":"2026-04-19T03:37:14.152632+00:00"}