Concurrency issues occur in applications when changes are made to a record in the database after a user retrieves a copy and before that user attempts to make changes. Entity Framework Core uses an optimistic concurrency strategy with concurrency tokens. In this section, Phil shows how this works and uses the DbUpdatedConcurrencyException to determine the original values, the current values, and the database values of the entity.
- [Instructor] Concurrency is when two processes…overlap in execution.…For Entity Framework and any database access layer,…this refers to data that was changed by another source…since it was retrieved.…That other source could be another user,…could be a trigger, could be some other DML call.…Pessimistic concurrency locks the record…until you're finished editing.…While this guarantees that you never have…a concurrency problem, it also drags…your performance down incredibly.…
Optimistic concurrency requires app…to remember the state of the data or specific…concurrency tokens when the item was retrieved.…It then uses these items to determine if the record…was changed since last pulled from the database.…Entity Framework uses optimistic concurrency…with concurrency tokens.…So what exactly is a concurrency token?…A concurrency token is a specific property or properties…on your model that Entity Framework will watch for…to determine if something has changed.…
Any field can be a concurrency token…by adding the [ConcurrencyCheck] data annotation…
- Entity Framework Core components and projects
- Working with scaffolded files
- Testing with xUnit
- Viewing generated SQL
- Composing queries
- Sorting and filtering results
- Working with aggregates
- Loading related data
- Logging and tracking
- Mapping functions
- Generics and delegates
- Checking concurrency
- Resiliency and transactions
Skill Level Intermediate
Learning Entity Framework Corewith Reynald Adolphe1h 35m Intermediate
1. Get to Know Entity Framework
2. Set the Stage
3. Querying Data: Part 1
4. Querying Data: Part 2
5. Advanced Query Features
6. Persisting Data
7. DbContext Options and Configuration
Thank you1m 23s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.