Skip to content
Preptima
mediumConceptScenarioMidSenior

A read-only endpoint that returns fifty thousand rows is slow and memory-heavy in EF Core. What is the context doing?

4 min readUpdated 2026-08-15

Answer

Short answer

The context snapshots every entity it loads so it can work out what changed at save time, which is useful for a handful of entities and pure overhead for a read.AsNoTracking removes the snapshot, and the same mechanism explains why a stray mutation on a tracked entity gets written even though you never called Update.

Was this answer helpful?

Likely follow-ups

  • You never called Update and the row changed anyway. How?
  • What does SaveChanges do when nothing was modified?
  • Two queries return the same row. Do you get one object or two?
  • When is tracking worth keeping on a large result set?

Related questions

Further reading