title: LINQ to SQL Insert Multiple Tables Question
body: <p>I have <strong>3 tables</strong>.  A <em>primary</em> <code>EmploymentPlan</code> table with <strong>PK</strong> <code>GUID EmploymentPlanID</code> and <strong>2 FK's</strong> <code>GUID PrevocServicesID</code> &amp; <code>GUID JobDevelopmentServicesID</code>.  There are of course other fields, almost exclusively <code>varchar()</code>.  Then the 2 secondary tables with the corresponding PK to the primary's FK's.</p>
  
  <p>I am trying to write the LINQ INSERT Method and am struggling with the creation of the keys.  Say I have a method like below.  Is that correct?  Will that even work?  Should I have seperate methods for each?</p>
  
  <p>Also, when <strong>inserting</strong> I didn't think I needed to provide the PK for a table.  It is <strong>auto-generated</strong>, no?</p>
  
  <p>Thanks.</p>
  
  <pre><code>public static void InsertEmploymentPlan(int planID, Guid employmentQuestionnaireID, string user, bool communityJob, bool jobDevelopmentServices, bool prevocServices, bool transitionedPrevocIntegrated, bool empServiceMatchPref)
  {
      using (var context = MatrixDataContext.Create())
      {
            var empPrevocID = Guid.NewGuid();
            var prevocPlan = new tblEmploymentPrevocService
            {
                EmploymentPrevocID = empPrevocID
            };
            context.tblEmploymentPrevocServices.InsertOnSubmit(prevocPlan);
  
            var empJobDevID = Guid.NewGuid();
            var jobDevPlan = new tblEmploymentJobDevelopmetService()
            {
                JobDevelopmentServicesID = empJobDevID
            };
            context.tblEmploymentJobDevelopmetServices.InsertOnSubmit(jobDevPlan);
  
            var empPlan = new tblEmploymentQuestionnaire
            {
                CommunityJob = communityJob,
                EmploymentQuestionnaireID = Guid.NewGuid(),
                InsertDate = DateTime.Now,
                InsertUser = user,
                JobDevelopmentServices = jobDevelopmentServices,
                JobDevelopmentServicesID =empJobDevID,
                PrevocServices = prevocServices,
                PrevocServicesID =empPrevocID,
                TransitionedPrevocToIntegrated =transitionedPrevocIntegrated,
                EmploymentServiceMatchPref = empServiceMatchPref 
            };
            context.tblEmploymentQuestionnaires.InsertOnSubmit(empPlan);
  
            context.SubmitChanges();
      }
  }
  </code></pre>
  
  <p>I understand I can use more then 1 InsertOnSubmit(), See <a href="https://stackoverflow.com/questions/1601805/question-about-updating-multiple-tables-with-linq-and-asp-net-mvc">this question</a>, I just don't understand how that would apply to my situation and the PK/FK creation.</p>