By default, Entity Framework Core loads entities into the Change Tracker. Loading entries that are consumed in a read only manner can be faster using no tracking queries. Phil shows how to turn off tracking at the query level as well as the context instance. Another way to turn off tracking is covered in the DbContext options section.
- [Instructor] Before we talk about tracking…versus no tracking queries, let's quickly review…the ChangeTracker.…The ChangeTracker provides access to appropriately…named change tracking information…and operations for the entities tracked by the context.…It also tracks the original values,…and it works with the DbContext when SaveChanges is called.…So as you might guess, there is some fairly heavy…lifting going on when you add an entity…into the ChangeTracker, that's a little facetious,…because it's still extremely performant,…but you can tweak a little bit more performance…out of it by not adding your entities…into the ChangeTracker.…
By default, when you load entities into a DbSet,…either using straight link or mixed link…and raw SQL or just from SQL,…they are added into the ChangeTracker.…When you specify a query to be no tracking,…then those entities are not added into the ChangeTracker,…and as I've stated, this can be more performant…in a strictly read only scenario.…You might be thinking, I never write read only applications,…
- 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.