Add an EF Core concurrency token such as rowversion. EF includes the original token in UPDATE/DELETE; if another writer changed the row, zero rows are affected and SaveChanges throws DbUpdateConcurrencyException. Example: public class Product { [Timestamp] public byte[] Version { get; set; } = []; } Return the token to the client (often as an ETag) and require it on updates. On conflict, reload current values and either reject with 409/412, merge explicitly, or retry only when the operation is safe. Never blindly overwrite. Tenant predicates must also include authenticated RestaurantId and OutletId. Test two contexts updating the same row so the conflict path is proven.
Backbencher Developer · · 0 likes