Common mistakes in EF Core
summary
Concrete failures and fixes with numbers: casting queries to IEnumerable loads 7 million rows into RAM (one run used ~30 GB and made the laptop unresponsive for 15 minutes), while keeping it as IQueryable lets SQL return COUNT() in ~130 ms (vs seconds) and avoids huge memory. Using AsNoTracking cuts allocations ~4x–5x and speeds queries, proper Skip/Take plus server-side Query.Count is ~18x faster for paging, cancellation token* stops SQL work and recovers throughput. Tests run with benchmark.us bombia on a Ryzen 9 5900X.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 3:19Why EF Core is great
- 15:39Seven deadly sins
- 17:05Mistake 1: IEnumerable vs IQueryable
- 24:17Mistake 2: Disabling AsNoTracking
- 28:59Mistake 3: Overusing includes
- 32:12Mistake 4: Ignoring pagination
- 36:52Mistake five: Not using cancellation tokens
- 40:51Mistake 6: Inefficient updates
- 43:48Advanced optimizations
- 53:30When to optimize
- 58:30Q&A
related talks
01h 04mCommon mistakes in EF Core
01h 04mCommon mistakes in EF Core
01h 00mGetting the best out of Entity Framework Core
01h 01mEntity Framework Core Unchained Getting the Best Performance from Your ORM
47mEF Core 6: Working on the Bucket List
59mEF Core 6: Fulfilling the Bucket List
01h 01m10 things you didn't know EF Core can do
01h 02mUnlocking the Full Potential: The Harmonious Dance of EF Core and SQL Server
