I want to create the following relationship. Obviously this is painfully basic but I’m falling at the first hurdle thanks to EF. In my database SubForm‘s primary key, Id, is a foreign key referencing Application.Id (enforcing the relationships). When I add a new Application EF complains that I don’t have a SubForm_Id row, I don’t want this as this would be obviously be a duplicate of the primary key. Can I add some annotations to the model to sort this out?

This brings me to another issue, if I want to add a new Application with a new SubForm to the database at the same time – how could I get the Application Id (it is defined in the db as an auto-increment int) to set it on the SubForm object, or can EF do this for me?
Help would be appreciated.
EF by convention assumes that your
Applicationtable has a scalar propertySubForm_Idwhen you have a navigational property of typeSubForm. You need to explicitly configure the Shared Primary Key mapping.You can insert both as follows