title: Entity framework DBcontext add child row
body: <p>As I understand, to add a child row, you can either do</p>
  
  <p>parent.Children.Add(child);</p>
  
  <p>or</p>
  
  <p>child.Parents= parent</p>
  
  <p>Then you can do myContext.SaveChanges();</p>
  
  <p>Somehow the second solution doesn't do the insert work at all. Here's my code: </p>
  
  <pre><code>        CountMaster countMaster = (from b in pMDataContext.CountMasters
                                     where b.ReportDate == reportDate &amp;&amp; b.Department == dept
                                     select b).SingleOrDefault();
  
  
  
          CountDetail countDetail = new CountDetail { CategoryId = 1, StatusId = 1 };
  
          //countMaster.CountDetails.Add(countDetail);
  
          countDetail.CountMaster = countMaster;
  
          pMDataContext.SaveChanges();
  </code></pre>