title: Error while deleting record from multiple table
body: <p>I have this page where I am trying to delete a record. But when I try to delete a record I am getting an error "<strong>The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.</strong>"</p>
  
  <p>Entity:</p>
  
  <pre><code>    public partial class ParentTable
  {
  
      public int p_id { get; set; }
      public string p_titl { get; set; }
      public string p_subtitle { get; set; }
      public string p_message { get; set; }
      public Nullable&lt;System.DateTime&gt; p_date { get; set; }
  
  
      public virtual ICollection&lt;ChildTable&gt; childtable { get; set; }
  }
  public partial class ChildTable
  {
      public long id { get; set; }
      public int p_id { get; set; }
      public string message { get; set; }
  
  
      public virtual ParentTable parenttable { get; set; }
  }
  </code></pre>
  
  <p>Delete code :</p>
  
  <pre><code>        public ActionResult Delete(int id)
      {            
              var deleteall = _db.ParentTable.Include(p =&gt; p.ChildTable).FirstOrDefault(p =&gt; p.p_id == id);
              _db.ParentTable.Remove(deleteall);          
              _db.SaveChanges();
               return RedirectToAction("Index");
      }
  </code></pre>