title: CTP5 POCO Code-Only, how to add master-detail records to DB
body: <p>I am trying EF CTP5 POCO, and converting from EF4 EntityModel to POCO Code Only Approach.</p>
  
  <pre><code>internal class InvoiceContext : DbContext
  {
      public DbSet&lt;Invoice&gt; Invoices {get; set;}
      public DbSet&lt;InvoiceLine&gt; InvoiceLines {get; set;}
  }
  
  public class Invoice
  {
      public Guid InvoiceId { get; set; }
      public virtual ICollection&lt;InvoiceLine&gt; Lines { get; set; }
  }
  
  public class InvoiceLine
  {
      public Guid InvoiceLineId { get; set; }
      public Guid InvoiceId { get; set; }
      public virtual Invoice Header { get; set; }
  }
  </code></pre>
  
  <p>so converting my old code from EF4 Model to POCO, I am supposed to add new Invoice and Lines. I used to create the master class and add the details to the instance of the master class itself.</p>
  
  <pre><code>var inv = new Invoice();
  inv.InvoiceId = Guid.NewGuid();
  var db = new InvoiceContext();
  db.Invoices.Add(inv);
  var invLine = new InvoiceLine();
  invLine = InvoiceLineId = Guid.NewGuid();
  inv.Lines.Add(invLine);
  </code></pre>
  
  <p>inv.Lines &lt;== is null at this point, so I cannot add a line to the instance of the invoice itself
  am I supposed to create a collection of InvoiceLines and set it, or is there some other way to do this.</p>
  
  <p>So in short, how I can add master/detail rows to my database using POCO Code Only (CTP5).</p>