The kangaroos are hopping...

The kangaroos are hopping... (Set FK values based on referenced principal on Add)

EF7 requires that all tracked entities have a unique primary key, even if it is temporary. Value generators are often used to obtain this primary key value. However, for identifying relationships (where the PK of an entity is also an FK and is completely or partially defined by the PK at the principal end of the relationship) the value used cannot be generated independently because it must match the principal PK. This change adds a value generator for FKs that uses navigation properties to find the principal and then takes the FK values from that principal. This makes it much easier to add a graph of entities without worrying about setting FK/PK values explicitly.

Note that it is necessary to find the principal in order to get the key for a dependent in an identifying relationship. This means that the principal must be added first so that it gets a valid key, or must at least have a valid key set with a direct reference from the dependent.