Updating tables with foreign key constraints

Only the relative ordering within the foreign key properties needs to be the same, the exact values assigned to Order do not need to match. in the following example 3 and 4 could be used in place of 1 and 2.

Note: In some cases it may not be possible for the column in the database to be non-nullable even though the property is required.

It’s not uncommon to describe your domain entities across a set of classes and then layer those classes to describe a complete entity.

For example, your could have a Passport class whose primary key is a combination of Passport Number and Issuing Country.

If you have entities with composite foreign keys then you must specify the same column ordering that you used for the corresponding primary key properties.

Code first leverages a programming pattern referred to as convention over configuration.

What this means is that code first will assume that your classes follow the conventions that EF uses.

As they are, the Blog and Post classes conveniently follow code first convention and required no tweaks to help EF work with them.