© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
11 replies
Messiah

❔ Singleton/semaphor EF Core

I need to make sure only one instance of EF Core (db context) runs at once, otherwise if two requests arrive at the same time, they'll both search for the username in the DB, see that they don't exist and try to create them, instead of redirecting the second request to a login logic.

How can something like this be accomplished? There's a billion different ways to implement this and I'm not entirely sure which one is the best/simplest for my use case. There's blocking collection, dictionaries, semaphores, semaphoreSlim, queues, concurrentqueues, list goes on.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

EF Core .NET 6 - Access DbContext from singleton service
C#CC# / help
4y ago
EF Core
C#CC# / help
2y ago
Ef core help
C#CC# / help
10mo ago
✅ EF Core Relationship
C#CC# / help
2y ago