Does the generated code "know" to insert the returned Pk of an entity where the Pk is defned as an Identity field into the related entities' fk fields?
Example: When entering a new order, the returned Pk is eg. 560 - will the code insert this value - 560 - into the related child records of the OrderDetails Enties?
Yes, as long as you've added the orderdetail entities to the order 's OrderDetails collection, so they're related in memory. When you save the order recursively, all entities are saved in 1 transaction, and pk/fk's are synced automatically.
Yes. It only doesn't sync in the situation:
PK 1:1 PK (fk side), and the FK side is NOT new. This is logical, as the PK of a non-new entity can't be set/shouldn't be set.