When persisting data, Entity Framework Core also saves related data. In this section, Phil demonstrates how EF saves changes to related data.
- [Instructor] EF Core is very intelligent…when handling related data.…When persisting changes to entities…any related data as defined by navigation properties…can be updated as well.…If one of a group of related entities is added…to the context,…all of the related entities are added.…Essentially once you add an entity into the context…then any reachable entity is added as well.…It's also smart enough to know…that if you move a child from one parent to another…it will update the foreign keys appropriately…on SaveChanges.…
It also protects you from making accidental deletes…if you do not have cascade turned on.…Just as in SQL Server if you delete a parent record,…and cascade delete is not enabled…on the foreign key relationship,…the change will fail.…The same happens with EF Core…when you call SaveChanges and cascade delete is not enabled.…Now let's look at an example of working with related data.…This is a fairly long test,…so I'm gonna go ahead and copy it in…from my prebuilt sample.…
And let's talk about it.…So a lot of this is stuff we have already done…
- Persisting data
- Tracking EntityState
- Configuring the DbContext
- Transactions across DbContexts
- Understanding the batching process
- Attaching and deleting detached entities
- Design time configuration
- Concurrency checking
- Using custom execution strategies
Skill Level Intermediate
Entity Framework Core Essential Training: 1with Phil Japikse3h 20m Intermediate
ASP.NET Core: Test-Driven Developmentwith Richard Rout37m 30s Intermediate
1. Persisting Data: Part 1
2. Persisting Data: Part 2
3. DbContext Options and Configuration
- 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.