I Googled it. I asked AI. I tried every Stack Overflow answer I could find. Nothing worked. Then I found the fix completely by accident — in a book I wasn't even reading for that reason.
Here's what was actually going on — explained simply enough that even if you're new to .NET, you'll get it immediately.
What I Was Trying to Do
I was working on a feature that needed to call two different API operations at the same time — concurrently. Run both, wait for both to finish, move on. Simple enough in theory.
Except the moment I did, my app threw this:
InvalidOperationException: A second operation was started on this context
instance before a previous operation completed. This is usually caused
by different threads using the same instance of DbContext.
I stared at it. Searched for it. Tried things for hours. Nothing matched my exact situation. I almost scrapped the whole concurrent approach and just ran them one after the other.
Then completely by accident — r
Discussion
Say something first
It all starts with you—share your thoughts now.