title: Update a list of data in the database
body: <pre><code>public ActionResult Event_History(int id = 0)
      {
          //set into false the active flag of the event
          Events_Info_tbl events = db.Events_Info_tbl.Find(id);
          events.is_active = false;
          db.Entry(events).State = EntityState.Modified;
  
          //set the category under this event into inactive
          List&lt;Events_Category_tbl&gt; category = new List&lt;Events_Category_tbl&gt;();
          category = db.Events_Category_tbl.Where(x=&gt;x.events_info_id==id).ToList();          
          foreach(var i in category){
              Events_Category_tbl cat = new Events_Category_tbl();
              cat.is_active = false;
              db.Entry(cat).State = EntityState.Modified; 
          }
  
          db.SaveChanges();
  
          TempData["MessageAlert"] = "Event is save in history!";
  
          return RedirectToAction("Index");
  
  
      }
  </code></pre>
  
  <p>Iam planning to set into inactive all the category belongs to that particular event but when I try to run this code an error displayed "An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key." pointing to this part of my code <code>db.Entry(cat).State = EntityState.Modified;</code></p>