title: Time Out in Deleting data in MySql using MVC Asp.net
body: <p>I have tow table in MySql</p>
  
  <p><strong>Students</strong>:</p>
  
  <pre><code>sCode sName depart
  </code></pre>
  
  <p><strong>Grades</strong></p>
  
  <pre><code>gID grade sCode
  </code></pre>
  
  <p>I want to delete students and related grades based on Depart parameter.</p>
  
  <p>I'm using Delete Depart Action in my studentContrller:</p>
  
  <pre><code>public ActionResult DeleteDepartConfirmd(string Depart)
      {
  
          var codes = db.students.Where(d =&gt; d.Depart == Depart).Select(s =&gt; s.sCode);
          var grades = db.grades.Where(s =&gt; codes.Contains(s.sCode));
          db.grades.RemoveRange(grades);
          db.SaveChanges();
  
          var students = db.students.Where(d =&gt; d.Depart == Depart);
          db.students.RemoveRange(students);
          db.SaveChanges();
          return RedirectToAction("studentsByDepart");
      }
  </code></pre>
  
  <p>The problem occourd in first stage in deleting records in Grade table.
  The process delete a few records (3-10) records and Time Out happened in browser as it takes a long time.
  My question: is my deleting method is the problem? if yes how can I make it better?</p>
  
  <p>The problem occurs in <strong>db.SaveChanges();</strong></p>
  
  <p>Note: I'm using Google cloud as MySql Host</p>