wasAsked.

Explain optimistic concurrency in Entity Framework Core and how you would present conflicts to a React user.

Razorpay · Full Stack Developer · 3-4-years · technical

Published

Year not specified · .NET, Entity Framework Core, React

Community answers

Posted by wasAsked editorial collection

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

Sign in to add your answer

Related interview topics