title: Entity Framework – Inserting into multiple tables using foreign key
body: <p>I am a relative newby to EF and have created a simple model (see below) using EF4.
  <img src="https://i.stack.imgur.com/pgFwz.png" alt="alt text"></p>
  
  <p>I am having a problem inserting a new record into the UserRecord entity and subsequently adding the UserDetail entity which uses the newly created UserRecordId as its primary key. The code shown below used to work when my database had a one-to-many relationship but when I change this to a one-to-one relationship I get the error highlighted in the image below. 
  <img src="https://i.stack.imgur.com/nEY8f.png" alt="alt text"></p>
  
  <p>I believe its not working as there is now no UserDetails property associated with the UserRecord because it’s  now a one-to-one relationship. My question is how do I now insert new UserRecord and corresponding UserDetail entities with a one-to-one relationship?</p>
  
  <p>Any help on this one is much appreciated as have been on searching the web and trying a variety of different things without success.</p>
  
  <p>Cheers</p>
  
  <p>Cragly</p>