The Entity Framework Core ChangeTracker uses EntityState to determine what operations need to executed when SaveChanges is called. This section covers the effect that Entity Operations have on the value of EntityState. Phil also covers the SaveChanges method and its effect on EntityState.
- [Narrator] An entity state determines…what operation needs to be done…to persist the data to the database.…The ChangeTracker, as we've discussed before,…tracks those changes to the entities in the DbContext.…And each tracked entity state…is either added, modified, deleted, or unchanged.…And then untracked entities have a state set to detached.…So how do we get those states set?…Well there's a series of entity operations.…
Add, update, and remove.…Each of those has a range version,…such as AddRange, UpdateRange, RemoveRange,…which operates on a list of entities.…And they all have Async versions as well.…So add…will add an entity…into the DbSet,…sets it to be tracked, and sets the entity state to added.…The update operations add the entities into the DbSet,…starts tracking them, and will either set the state…to modified or added.…
If the primary key values are existent…it will be considered to be modified…and if they do not have a primary key values…it will be considered to be added.…We'll cover that a lot more…in the detached entities section coming up soon,…
- 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.