From the course: Using Entity Framework Core with Legacy Databases
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Adding concurrency tokens and timestamps
From the course: Using Entity Framework Core with Legacy Databases
Adding concurrency tokens and timestamps
- Usually, applications against the database allow more than one user at a time. However, if two users modify a row at the same time, there's a problem, who's modification do we keep. We need to refresh the data and have the second user try again with more recent data, or find some other way to resolve the issue. Concurrency tokens allow entity framework to track specific columns for changes to ensure that a field within a row has not been modified since we last retrieved the data for it. In the order entity, we are using the last updated field, to serve this purpose. Let's start under the model folder with our data context. Scroll down to the order section, and find the last update property definition. The column has isRowVersion, which we mentioned before, which includes isConcurrencyToken. Since the last update is a rowVersion field, it will be updated when any row in this field is updated. If this field is different from when we first pulled the item, when we go to save the same…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Why change the generated model2m 8s
-
(Locked)
Changing names1m 49s
-
(Locked)
Using shadow properties2m 23s
-
(Locked)
Generated properties and default values4m 34s
-
(Locked)
Using backing fields3m 35s
-
(Locked)
Adding and altering indexes3m 38s
-
(Locked)
Adding concurrency tokens and timestamps4m 8s
-
(Locked)
-
-
-