title: Insert data simultaneously in entity having one to many relationship
body: <p>I have two entities: Student and Enrollement having a one-to-many relationship. 
  The entities looks like</p>
  
  <pre><code>public class Student{
   [Key]
   public int Studentid {get; set;}
   public string fname{get; set;}
   public string lname{get; set;}
   public virtual ICollection&lt;Enrollement&gt; Enrollement_E{ get; set; }
   }
  
   public class Enrollement{
   [Key]
   public int EnrolId {get; set;}
  
   [ForeignKey("Studentid ")]
   public int Student{get; set;}
   public string kk{get; set;}
   public virtual Student Student_E { get; set; }
   }
  </code></pre>
  
  <p>Studentid is an autoincremented primary key and serve as foreign key in the enrollment table.  I am trying to insert data into both table. Both inserts should not commit if either 1 fails. So, I have the following code.</p>
  
  <pre><code>try{
    repository.stu.insert(new student{fname = "fname", lname="lname"});
    repository.enr.insert(new Enrollement{student=???, kk="test"});
  }
  finally{
    repository.save();
  }
  </code></pre>
  
  <p>How am I supposed to pass in the foreign key to the Enrollement record when the data has not been saved. Or is there another way of doing this?</p>