title: Store update, insert, or delete statement affected an unexpected . Entities modified or deleted since entities were loaded
body: <p>I am using MVC for my project .</p>
  
  <p>I added a controller named <code>group</code> and in this controller i have some action as usual like <em>create</em> and <em>edit</em> and etc .</p>
  
  <p>but my problem refers to <code>edit</code> method As you can see here :</p>
  
  <pre><code>public ActionResult Edit(int GroupId)
  {
      ViewBag.groupIdLST = new SelectList(OBJgroupRepository.FindBy(i =&gt; i.GroupId == null).ToList(), "Id",
      ViewBag.GroupType = new SelectList(OBJgroupRepository.FindBy(i =&gt; i.GroupId == null).ToList(), "name",
      DomainClass.Group tg = OBJgroupRepository.FindBy(i =&gt; i.Id == GroupId).First();
      return View(tg);
  }
  [HttpPost]
  public ActionResult Edit(Group gr)
  {
      if (ModelState.IsValid)
      {
          OBJgroupRepository.Edit(gr);
          OBJgroupRepository.Save();
      }
      TempData["success"] = "اطلاعات با موفقیت ویرایش شد";
      return RedirectToAction("Create");
  }
  </code></pre>
  
  <p>When I click on edit button i got this error :</p>
  
  <blockquote>
    <p>Store update, insert, or delete statement affected an unexpected
    number of rows (0). Entities may have been modified or deleted since
    entities were loaded. See
    <a href="http://go.microsoft.com/fwlink/?LinkId=472540" rel="nofollow">http://go.microsoft.com/fwlink/?LinkId=472540</a> for information on
    understanding and handling optimistic concurrency exceptions.</p>
  </blockquote>
  
  <p>My edit and save method :</p>
  
  <pre><code>public virtual void Edit(T entity)
  {
      _entities.Entry(entity).State = System.Data.Entity.EntityState.Modified;
  }
  
  public virtual void Save()
  {
      try
      {
          _entities.SaveChanges();
      }
      catch (DbEntityValidationException e)
      {
          foreach (var eve in e.EntityValidationErrors)
          {
              Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                  eve.Entry.Entity.GetType().Name, eve.Entry.State);
              foreach (var ve in eve.ValidationErrors)
              {
                  Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                      ve.PropertyName, ve.ErrorMessage);
              }
          }
          throw;
      }
  }
  </code></pre>
  
  <p>my repository :</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using DomainClass;
  using ProjectModel;
  
  namespace Repository
  {
      public class GroupRepository : GenericRepository&lt;DataAccessModelContainer, Group&gt;
      {
      }
  }
  </code></pre>
  
  <p>Any details are available as requested.</p>
  
  <p>Best regards .</p>