Based on the navigation attributes, EF does determine the suitable order. There's still a problem. There might be a few issues.
Why do you use
? Or does the database create and maintain the ids? Don't you want the database if it is?
Moreover, is the agent's main key nullable? Is that accurate? Primary keys shouldn't be allowed to be null...
No, you shouldn't have to set
in a typical one-to-many arrangement. This might be perplexing to EF.