public ActionResult Edit([Bind(Include = "Id,Name,Category,Price,UserID")] Item item) { if (ModelState.IsValid) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.AspNetUsers, "Id", "Email", item.UserID); return(View(item)); }
public static void UpdateEF() { using (TestEntities context = new TestEntities()) { User user = new User { Gender = Gender.Male, Id = 1, Name = "teste", DateCreate = DateTime.Now }; watch.Restart(); context.Entry(user).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); Console.WriteLine("Update All - {0}ms", watch.ElapsedMilliseconds); } Console.WriteLine(); }