title: Update of a row in asp.net MVC 3
body: <p>I've got an Edit action like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
  public ActionResult Edit(UserModel user1)
  {
      if (ModelState.IsValid)
      {
          UserManager um = new UserManager();
          String mail = User.Identity.Name;
          long id = um.getUserIDByemail(mail);
          user user = db.users.Single(u =&gt; u.user_id == id);
          user.name = user1.name;
          user.cellno = user1.cellno;
          db.users.Attach(user);
          db.ObjectStateManager.ChangeObjectState(user, EntityState.Modified);
          db.SaveChanges();
          return RedirectToAction("Index");
      }
      return View(user1);
  }
  </code></pre>
  
  <p>I've got user object exactly what I want to update. Two properties (<code>name</code>, <code>cellno</code>) of user comes from a view. When I run it I get an error: </p>
  
  <blockquote>
    <p>The object cannot be attached because it is already in the object context. An object can only be reattached when it is in an unchanged state.</p>
  </blockquote>