Skip to content
Preptima
mediumConceptCodingMidSeniorStaff

Two users edit the same record and both save. What does EF Core do about it?

EF Core optimistic concurrency uses a rowversion or concurrency token so a stale update affects zero rows instead of overwriting another user's change. The application must then merge, retry or ask the user.

5 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

Add a concurrency token such as rowversion and handle DbUpdateConcurrencyException. When two users edit the same row, EF Core detects the stale write and lets you choose merge, retry or conflict resolution.

Was this answer helpful?

Likely follow-ups

  • The user should not lose the fifteen minutes of edits they just typed. What does resolution look like on their screen?
  • Why is a DateTime LastModified column a weak concurrency token, and what would make it adequate?
  • When would you take a pessimistic lock instead, and what does that cost under load?
  • Where does the token live while the entity is edited in a disconnected web form and posted back?

Related questions

Further reading