I'm using an Edit View in ASP.NET MVC and after an edit it returns the Edited Entity back. What's the best way to get the edited values back to the databse.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, Movies EditedMovie)
{
var orginalMovie = _db_linq.Movies.First(e => e.Id == id);
if (!ModelState.IsValid)
return View(orginalMovie);
_db_linq.Movies.Attach(EditedMovie, true);
_db_linq.SubmitChanges();
return RedirectToAction("Index");
}
Returns the Error "Cannot add an entity with a key that is already in use."
orginalMovie = EditedMovie;
doesn't work,too
I have too copy each property seperate, i.e.
orginalMovie.Name = EditedMovie.Name;