Join Richard Goforth for an in-depth discussion in this video Alternate keys and multicolumn keys, part of Accessing Existing Databases with Entity Framework Core.
- [Instructor] Some relationships,…especially in legacy databases,…don't use the primary key of a table…to relate to another table.…We're going to add a relationship…to a table on an alternate key.…In our model we have Salesperson and SalesGroup.…A Salesperson has a SalesGroup state and a SalesGroup type…but no navigation property to the SalesGroup itself.…It would also be nice if we could add…a collection of salespeople to a SalesGroup,…allowing us to get the collection of people…that belong to a SalesGroup.…We'll go back to the Salesperson model first.…
The first thing that I'm noticing here is…that we have a Salesperson navigation…and inverse Salesperson navigation property.…I don't expect these on the model.…So let's go look at the context…and see where they came from.…We'll scroll down to the Salesperson.…We see that those navigation properties…are part of a form key…that references the SalespersonId.…Since this form key references this same table,…we can assume that it was added in error.…Let's remove this form key and navigation properties.…
- Setting up your project
- Connecting to a legacy database
- Scaffolding an initial model and context
- Improving the model
- Updating properties and indexes
- Adding concurrency tokens and timestamps
- Creating complex relationships
- Working with non-Microsoft databases such as SQLite and PostgreSQL
Skill Level Intermediate
SQL Server 2014 Essential Trainingwith Martin Guidry3h 51m Intermediate
Microsoft SQL Server 2014: Backup and Recoverywith Martin Guidry1h 22m Intermediate
1. Get Started with EF Core: On Your Legacy Database
2. Improve the Model
3. Model Complex Relationships
4. Work with Non-Microsoft Databases
- 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.