Web applications typically have detached entities that must be added to the Entity Framework Core Change Tracker for persistance of changes. All of the entity operations—Add, Update, and Remove—attach entities as well as the special Attach command. The state that gets assigned an entity when attached depends on the command used and the values of the primary key or keys. In this section, Phil explains the nuances of entity attachment, then demonstrates the different scenarios.
- [Instructor] In this section on…tracking versus no tracking queries,…I mentioned the potential performance improvement…when you use untracked entities…and web applications typically work…with detached entities,…you create a context, you return the requested data…to the user and that context goes away.…At some point in time, the user might submit…changes back to the server where model binding,…if you're using ASP.NET Core…will then reconstitute an object.…
this object is not attached to any context.…So then you can attach it to the DbContext…using attach, add, update or remove on the DbContext…and we saw this in action earlier.…You can also specifically detach an entity…from a DbContext by setting the entity state to detached.…As I mentioned, when we were talking…about entity operations, the entity state…after an attached operation can vary based on…the method used and the primary key types in values.…
So if your entity is missing,…or has default primary key values,…then when you attach, add or update,…it will be set to the added state.…
- 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.