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.