I created one CRUD Operation and in that, I faced one error like below while trying to delete one record.
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 http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions.
I created below action method for delete record.
[HttpPost]
public ActionResult Delete(tblMember objMember)
{
_memberContext.Entry(objMember).State = EntityState.Deleted;
int a = _memberContext.SaveChanges();
if (a > 0)
{
TempData["DeleteMessage"] = "<script>alert('Data Deleted')</script>";
}
else
{
TempData["DeleteMessage"] = "<script>alert('Data Not Deleted')</script>";
}
return RedirectToAction("MemberList");
}