title: Editing User Profile Data in SimpleMembership
body: <p>I am using SimpleMembership in an MVC4 web app.  I can't figure out how to edit the profile information.  I thought I could do it just as you do any other table.  </p>
  
  <pre><code>        [HttpPost]
          public ActionResult EditUser(UserProfile user)
          {
              if (ModelState.IsValid)
              {
                  udb.Entry(user).State = EntityState.Modified;
                  udb.SaveChanges();
                  return RedirectToAction("Index");
              }
  </code></pre>
  
  <p>But I get an error saying entity state does not exist in the current context.  My context is defined as follows at the top of the controller.  </p>
  
  <pre><code>private UsersContext udb = new UsersContext();
  </code></pre>
  
  <p>I can find plenty of references on access profile data but nothing for editing the data.  How can I save the edited UserProfile data back to the db?</p>
  
  <p>EDIT: I was able to resolve the entityState error -- I had to include system.data and system.data.entity.  However now when I run I get an error on edit which says unexpected number of rows modified (0). and points to the udb.SaveChanges() line.  Still can't figure out how to modify UserProfile data elements.</p>