title: Entity Framework 6 update a table and insert into foreign key related tables
body: <p>Not quiet sure how to word the title for this one so feel free to edit if it isn't accurate.</p>
  
  <p>Using an example, what I am trying to accomplish is update a record in table foo, and then create new records in a subsequent table that has the foo tables PK as foreign key, think One-to-Many relationship.</p>
  
  <p>How do I update a table that has foreign key constraints and create a new related record(s) in these subsequent table(s)?</p>
  
  <p>Currently I am using Entity Framework 6 to .Add and .Attach entities to the context and save them to the database.</p>
  
  <p><em>Edit</em></p>
  
  <p>To clarify further what I am trying to achieve, the below object is a cut down made up example what I am trying to save to the context. If I try to .Add intObj after "Billy Bob" has already been created because he has bought a new car, another service, or his tyres have changed it will create a new Billy Bob record (duplicate) and the corresponding related tables.</p>
  
  <pre><code>        intObj.FirstName = "Billy";
          intObj.Lastname = "Bob";
          intObj.Important = 100;
          intObj.LastSeen = DateTime.Now.Date;
          intObj.Cars = new List&lt;Car&gt;{
              new Car{
                  Model = "Commodore",
                  Make = "Holden",
                  YearMade = DateTime.Today.Date,
                  Odometer = 15000,
                  EmailWordCount = 500,
                  TyreStatuss = new List&lt;TyreStatus&gt;{
                      new TyreStatus{
                          Tyre1 = "Good",
                          Tyre2 = "Good",
                          Tyre3 = "Okay",
                          Tyre4 = "Okay"
                          }                                 
                  },
                  Services = new List&lt;Service&gt;{
                      new Service{
                          Cost = "$500",
                          Time = "2 Days",
                          Date = DateTime.Today
                      }
                  },
              }
          };
  </code></pre>
  
  <p>Thanks </p>