The Slow Page Walkthrough
This is the most common EF Core scenario question in .NET interviews, and it opens like this: "Our candidate list page takes 9 seconds to load. Walk me through how you'd approach it." The interviewer is not testing whether you know the fix β they're testing whether you diagnose in order instead of guessing. A strong candidate narrates a process; a weak one blurts "add an index."
Step one: measure before touching anything
Say it out loud: "First I'd confirm where the time goes." Name your tools β EF Core logging
(LogTo or EnableSensitiveDataLogging in dev), SQL Server Query Store or Profiler, and
Application Insights if it's deployed. The single most valuable sentence in this answer:
"I want to know if it's one slow query or two hundred fast ones." That sentence tells the
interviewer you know the N+1 problem exists before you've even named it.
The usual suspects, in the order you'd check them
- N+1 queries β the page loops over candidates and lazily loads each one's transcripts.
Fix:
Include()for true object graphs, or better, a projection. - Missing projection β the query pulls entire entities (every column, every related row)
to render four columns. Fix:
.Select(c => new CandidateRowVm { ... })so SQL returns only what the screen needs. Projections also skip the change tracker entirely. - Tracking overhead β a read-only list doesn't need change tracking.
AsNoTracking()is cheap insurance on large result sets. - Missing index / bad SQL β capture the generated SQL, look at the execution plan, check
for scans on the filter and sort columns. Mention that
Skip/Takepaging without a supporting index still scans.
Close the loop: "Then I'd re-measure and confirm the page is fast before calling it done." Diagnose β fix β verify is the shape they want.
Answers that fall flat
- Jumping straight to "add caching" or "add an index" with no measurement.
- Not knowing what N+1 is, or claiming
Include()on everything is the fix (it can make cartesian-explosion queries worse β mentionAsSplitQuery()as the counter-move). - Suggesting
.ToList()early "to make it faster" β that materializes the whole table and moves filtering into memory.
Practice prompts
- Rehearse the 9-second answer out loud in under two minutes: measure, name the four suspects in order, verify.
- Write a projection query for a candidate list showing name, agency, and transcript count β
no
Include()allowed. - Explain to a rubber duck when
Include()beats a projection, and when it doesn't.