The N+1 Query Problem in EF Core: Detection, Diagnosis, and Permanent Fixes

The N+1 Query Problem in EF Core: Detection, Diagnosis, and Permanent Fixes

An order summary page renders in 40 milliseconds against your development database. The same page takes eleven seconds in production. You open the profiler, and the controller method looks clean. You reread the LINQ, and it reads correctly. You check the indexes, and every column you need is covered. The code passed review. The tests are green. And the page …

Continue Reading
Add vs AddRange in EF Core: The Performance Myth You Need to Stop Repeating

Add vs AddRange in EF Core: The Performance Myth You Need to Stop Repeating

Somebody told you never to call Add() in a loop. Maybe it was a senior developer during code review. Maybe it was a Stack Overflow answer with four hundred upvotes. Maybe it was a blog post that ranks on page one for “improve entity framework performance.” The advice sounded authoritative: Add() forces a DetectChanges scan on every call, and that …

Continue Reading
5 EF Core Performance Anti-Patterns That Entity Framework Extensions Eliminates

5 EF Core Performance Anti-Patterns That Entity Framework Extensions Eliminates

The Code You Already Wrote Every .NET team has at least one of these in production. It looked fine in review. It passed unit tests. It worked in staging against the seed data. Then real traffic hit, and now somebody is on call at three in the morning trying to work out why the nightly job has been running for …

Continue Reading
Blueprint-style banner showing Bulk Synchronize in EF Core with Insert, Update, Delete steps on the left and a data sync diagram on the right between SOURCE LIST, SYNC, and TABLE.

BulkSynchronize in EF Core: Mirror Your Data in One Operation

The Function Everyone Has Written, Nobody Loves If your codebase has a method called something like SyncProducts(), RefreshMetrics(), or UpdateFromFeed(), it probably looks something like this: It looks fine in code review. It passes the unit tests. It scales like a wet match. Three things go wrong as data volume grows. Loading the existing rows pulls everything into the change …

Continue Reading
Scaling EF Core for Data Imports: From CSV Files to Millions of Database Rows

Scaling EF Core for Data Imports: From CSV Files to Millions of Database Rows

The Import Job Nobody Wants to Own Every team has one. It might be called an import service, a feed processor, or a sync job. The name varies. What stays constant is the shape of the problem: a large file arrives on schedule, and someone needs to get its contents into a database accurately, quickly, and without duplicating data already …

Continue Reading
BulkMerge (Upsert) in EF Core: How to Insert-or-Update Without the Headache

BulkMerge (Upsert) in EF Core: How to Insert-or-Update Without the Headache

Picture this. Your inbox lights up at 7:14 AM. A supplier just pushed 50,000 product records to your endpoint. Half are new. The other half are updates to products already sitting in your database. You have no idea which is which. The feed does not tell you. The records do not carry your internal primary keys. And the import job …

Continue Reading
Pagination in EF Core, Continued: Sortable Grids, htmx, and the Indexing Cost

Pagination in EF Core, Continued: Sortable Grids, htmx, and the Indexing Cost

The first post in this series made a clean case for keyset pagination over Skip/Take. Readers on LinkedIn pushed back with a fair question I’d dodged: what about sortable grids where the user picks the column? The post showed ORDER BY Id, which is the easy case. Real apps have grids with eight clickable column headers and a “sort direction” …

Continue Reading
Pagination in Entity Framework Core: Why Skip/Take Falls Apart on Hot Tables

Pagination in Entity Framework Core: Why Skip/Take Falls Apart on Hot Tables

If you’ve built an ASP.NET Core API or list view backed by Entity Framework Core, you’ve almost certainly written something like this: It works. It matches the page-number UI most users expect. Every EF Core tutorial uses it. It’s also the wrong default once your table grows beyond a few hundred thousand rows or begins seeing concurrent writes. This post …

Continue Reading
EF Core Bulk Insert: The Complete Guide to Inserting Thousands of Rows Without the Wait

EF Core Bulk Insert: The Complete Guide to Inserting Thousands of Rows Without the Wait

This post is sponsored by ZZZ Projects. You have written this loop. Every .NET developer has. It looks fine in a code review. It passes unit tests. It works against your local database with 200 sample rows in twelve milliseconds. Then production calls. The nightly import runs against 300,000 product records. By 3am your monitoring dashboard turns red, your DBA …

Continue Reading
How to Delete and Update Millions of Rows in EF Core Without Loading a Single Entity

How to Delete and Update Millions of Rows in EF Core Without Loading a Single Entity

This post is sponsored by ZZZ Projects. The Code Every Developer Has Written and Regretted Most EF Core performance disasters are not exotic edge cases. They get written in the first sprint, look clean in code review, and only reveal themselves when row counts hit production scale. The pattern below has ended more than a few on-call rotations badly: On …

Continue Reading