Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Let's see how we can require each comic book to be associated with a series by explicitly adding a foreign key property to the ComicBook entity class.
Follow Along
To follow along commiting your changes to this course, you'll need to fork the dotnet-comic-book-gallery-model repo. Then you can clone, commit, and push your changes to your fork like this:
git clone <your-fork>
cd dotnet-comic-book-gallery-model
git checkout tags/v3.3 -b defining-foreign-key-property
Foreign Key Property Name Conventions
When generating the in-memory entity data model, EF will will attempt to identify foreign key properties by checking if any of the entity's properties following these naming conventions:
- {Navigation Property Name}{Principal Primary Key Property Name}
- {Principal Class Name}{Primary Key Property Name}
- {Principal Primary Key Property Name}
You need to sign up for Treehouse in order to download course files.
Sign up