title: Inserting Rows in Relationship using a Strongly Typed DataSet
body: <p>I'm using ADO.NET with a strongly typed dataset in C# (.NET 3.5). I want to insert a new row to two tables which are related in an 1:n relation.</p>
  
  <p>The table <code>Attachments</code> holds the primary key part of the relation and the table <code>LicenseAttachments</code> holds the foreign key part.</p>
  
  <pre><code>AttachmentsDataSet.InvoiceRow invoice; // Set to a valid row, also referenced in InvoiceAttachments
  AttachmentsDataSet.AttachmentsRow attachment;
  attachment = attachmentsDataSet.Attachments.AddAttachmentsRow("Name", "Description");
  attachmentsDataSet.InvoiceAttachments.AddInvoiceAttachmentsRow(invoice, attachment);
  </code></pre>
  
  <p>Of course when I first update the <code>InvoicesAttachments</code> table, I'll get a foreign key violation from the SQL server, so I tried updating the <code>Attachments</code> table first, which will create the rows, but will remove the attachment association in the <code>InvoiceAttachments</code> table. Why?</p>
  
  <p>How do I solve this problem?</p>