EF Core defaults to last-write-wins behavior, which can silently overwrite concurrent updates without any warning. Two explicit strategies exist to handle this: optimistic concurrency uses a RowVersion column to detect conflicts at save time and throw a DbUpdateConcurrencyException, while pessimistic concurrency uses database locks to prevent conflicts upfront. Optimistic concurrency suits infrequent, user-driven conflicts in stateless web apps; pessimistic locking fits short, system-driven operations with high contention. The key takeaway is to choose deliberately rather than accepting the silent-overwrite default.
Table of contents
Designing Intentional Conflict Handling in .NET ApplicationsThe Default: Silent OverwritesOptimistic Concurrency: Detect and RespondPessimistic Concurrency: Coordinate Up FrontChoosing DeliberatelySort: