Note that there are some explanatory texts on larger screens.

plurals
  1. PODbUpdateConcurrencyException will always fire
    text
    copied!<p>I have the following Action method, fr editing an object and i am checking for Concurrency exception:-</p> <pre><code>[HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit(Group group) { try { if (ModelState.IsValid) { groupRepository.InsertOrUpdate(group); groupRepository.Save(); return RedirectToAction("Index"); } } catch (DbUpdateConcurrencyException ex) { var entry = ex.Entries.Single(); var clientValues = (Group)entry.Entity; ModelState.AddModelError(string.Empty, "The record you attempted to edit " + "was modified by another user after you got the original value. The " + "edit operation was canceled and the current values in the database " + "have been displayed. If you still want to edit this record, click " + "the Save button again. Otherwise click the Back to List hyperlink."); } catch (DbUpdateException) { ModelState.AddModelError(string.Empty, " An Error Occured, please check the Group name for uniquenee."); } catch (DataException) { ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator.");} return View(group); } </code></pre> <p>and I have the following Repository method:-</p> <pre><code>public void InsertOrUpdate(Group group) { if (group.GroupID == default(int)) { // New entity context.Groups.Add(group); } else { // Existing entity context.Entry(group).State = EntityState.Modified; } } </code></pre> <p>Finally on the view i added the following :-</p> <pre><code>@using (Html.BeginForm()) { @Html.ValidationSummary(true) @Html.HiddenFor(model =&gt; model.GroupID) @Html.HiddenFor(model =&gt; model.timestamp) @Html.Partial("_CreateOrEdit", Model) </code></pre> <p>But currently whenever the user tries to edit the object, made the DbUpdateConcurrency is raised. so what might be causing this ? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload