title: Delete parent and child records without using on delete cascade
body: <p>So, let's we go to the point. I have a project that where the user can delete the records from the database, but of course if I delete the parent record, I will get an error because it has child records in another table. So, what I want to do is I want to delete the parent records, and when I delete it, all the rows in child records that include the parents key or primary key will be deleted as well without using cascade.</p>
  
  <p>Here is the code for example :</p>
  
  <pre><code>if (row != -1)
          {
              tbl_employee.Rows.RemoveAt(row);
  
              int id = Convert.ToInt32(txt_employeeid.Text.ToString());
              employee emp = db.employees.Single(x =&gt; x.employeeid == id);
              db.employees.DeleteOnSubmit(emp);
  db.SubmitChanges();
          }
          else
          {
              MessageBox.Show("Click the row first!");
  
          }
  </code></pre>
  
  <p>But, I have an error <code>The DELETE statement conflicted with the REFERENCE constraint</code>. I know I can use <code>on delete cascade</code>, but is there any other thing for delete the child records without using it?</p>