Entity Framework has long supported server generated properties, and updating entities with those values during the SaveChanges operation. New in Entity Framework Core is the ability to also set server generated properties client side and EF Core honors those values. Of course, there are some restricitions and Phil demonstrates how all of this works, including enabling identity insert to set an Identity column client side.
- [Instructor] When creating a new instance of an entity,…server generated properties,…such as sequence, timestamps, GUIDs, etc.,…are set to C# default values.…When tracked using Add, server generated primary keys…are set to a unique value until the entity is persisted.…For example, an integer sequence would be set…to a negative number and additional items…that are added will have different negative numbers.…
This allows you to operate on groups of entities at a time…without worrying about the child entities getting lost…with duplicate primary keys in non-persisted entities.…After a successful Insert or Update,…EF fetches the server generated data…into the tracked entities.…So once you call SaveChanges(),…and that SaveChanges() is successful,…all of your entities will have their values populated.…
A new feature in Entity Framework Core…is setting explicit values for generated properties.…So server-side generated values can be set…and the values will be honored on save.…However, if you are setting the value on IDENTITY columns,…
- 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.