public ActionResult Edit(Artist artist) { using (var ctx = new ChinookEntities()) { var a = ctx.Artists.Single(t => t.ArtistId == artist.ArtistId); a.Name = artist.Name; ctx.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Create(Artist artist) { using (var ctx = new ChinookEntities()) { var id = ctx.Artists.OrderByDescending(t => t.ArtistId).First().ArtistId; artist.ArtistId = ++id; ctx.Artists.Add(artist); ctx.SaveChanges(); return RedirectToAction("Index"); } }