Загрузка...

Stop Running EF Core Queries One-By-One (Do This Instead)

Want to master Clean Architecture? Go here: https://bit.ly/3PupkOJ
Want to unlock Modular Monoliths? Go here: https://bit.ly/3SXlzSt

🚀 Want a real performance boost in EF Core?

A common API pattern is loading multiple independent datasets in a single request (think dashboards: users + orders + logs). The naïve approach runs queries sequentially… and your latency adds up fast.

So you try Task.WhenAll — and EF Core throws the classic error:
“A second operation was started on this context…”

In this video, I’ll show you the right way to execute EF Core queries concurrently without crashing your app.
- What you’ll learn
- Why DbContext can’t run concurrent operations (even with async/await)
- The dashboard scenario where parallel queries make a big difference
- How to use IDbContextFactory to create a separate DbContext per query
- A clean helper pattern to keep query code reusable
- How to verify concurrency with tracing + measure the win
- Tradeoffs to consider (more contexts, more connections)

DbContext is Not Thread-Safe: Parallelizing EF Core Queries the Right Way
https://www.milanjovanovic.tech/blog/dbcontext-is-not-thread-safe-parallelizing-ef-core-queries-the-right-way

Check out my courses:
https://www.milanjovanovic.tech/courses

Read my Blog here:
https://www.milanjovanovic.tech/blog

Join my weekly .NET newsletter:
https://www.milanjovanovic.tech

Chapters

Видео Stop Running EF Core Queries One-By-One (Do This Instead) канала Milan Jovanović
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять