Two users edit the same ASP.NET Core record and the second save overwrites the first. How would you fix it?
Detailed Explanation
This is a classic lost-update scenario. Add an optimistic concurrency token, commonly a SQL Server rowversion column, and configure EF Core to treat it as a concurrency token.
When the edit page is loaded, retain the original rowversion. EF Core includes that original token in the UPDATE predicate. If another user has changed the record, the UPDATE affects no rows and EF Core raises DbUpdateConcurrencyException.
The application should catch that exception and apply a defined business policy: show the current database values, let the user review differences, merge compatible changes, cancel, or explicitly retry. Silently overwriting the newer data should not be the default.
This is a strong interview scenario because it connects SQL Server concurrency control with real ASP.NET Core/EF Core application behavior.
Code Example
// EF Core model example
[Timestamp]
public byte[] RowVersion { get; set; } = Array.Empty<byte>();
// SaveChangesAsync may throw DbUpdateConcurrencyException
// when the original RowVersion no longer matches.