1

Here is my edit action method:

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include ="ID,Title,Issue,CreationDate,Status,Priority,UserID")] Ticket ticket)
{
    if (ModelState.IsValid)
    {              
        db.Entry(ticket).State = EntityState.Modified;
        db.SaveChanges();
        return RedirectToAction("Index");
    }
    ViewBag.UserID = new SelectList(db.Users, "Id", "UserName", ticket.UserID);
    return View(ticket);
}

A System.Data.Entity.Infrastructure.DbUpdateException occurs every time at db.SaveChanges(). My create action method is very similar but works fine.

I have another table in my db called Updates which has a foreign key TicketID linking it to a Ticket. Each Ticket can have multiple Updates. I think this may be what's causing the issue but I'm not sure how to fix it as I'm quiet new to mvc.

4
  • 1
    The DbUpdateException is caused by mostly database constraint violations. Show us the error message so we pinpoint the exact violation. Commented May 9, 2014 at 4:50
  • Why do you have an extra comma at the end of the list of properties you include during model binding? Does that cause the problem? Commented May 9, 2014 at 5:59
  • No that extra comma shouldn't be there but I have removed it now and it didn't solve the problem. Commented May 9, 2014 at 10:17
  • I'm just getting a System.Data.Entity.Infrastructure.DbUpdateException. How do I view the inner exception? Commented May 9, 2014 at 13:25

1 Answer 1

0

You can try to make break point to your method and there you inspect this object and its parameters that controller edit method receive. It may be problem that you are not passing all needed parameters from your view to controller. Check that first.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.