title: Insert record in child table when parent record already exists using Entity Framework code first
body: <p>I have some Parent records already inserted in the database. Now i want to add some child records. To do this I followed following steps:</p>
  
  <ol>
  <li>Retrieve the Parent(A) records</li>
  <li>Create a new child(B) record</li>
  <li>Add parent record to the Navigation property of Child. B.A = A</li>
  <li>Call SaveChanges.</li>
  </ol>
  
  <p>The problem is when i do this EF inserts a New Parent and then add the child with a foreign key pointing to new newly inserted parent instead of inserting just the child with mapping to already existing parent. I also checked the parent's primary key when saving the child and it does exists in the database.</p>
  
  <p>Note that i am using database generated identity for Parent and Child.
  One thing i noticed was if I add/Save Parent and Child from the same context object then it works fine.</p>
  
  <p>Need to fix this asap. Any help will be greatly appreciated.</p>