title: How to update a record from database via ADO.NET Entity Framework?
body: <p>My WPF desktop-based application uses ADO.Net Entity Framework in order to connect to SQL Server database. In one of the windows I have a <code>DataGrid</code> with all data from <code>tbl_users</code>, when user selects one of the rows (records) and clicks on <em>Edit</em>, application opens a new window with form, that includes all data that user can edit/update.</p>
  
  <p>My question is how to save changes (update/edit) of one of the table's values to database via ADO.NET Entity Framework?</p>
  
  <p>Here are some code snippets that help understand a situation:</p>
  
  <p>1 - Edit window constructor</p>
  
  <pre><code>public object objToBeEdited;
  
  public WinWorkers_EditWorker(tbl_users userToBeEdited)
  {
      this.Title = Glidus.Properties.Resources.WinWorkers_EditWorker_WinName + Glidus.Properties.Resources.WinApp_WinName;
  }
  </code></pre>
  
  <p>2 - Method Update, that doesn't work</p>
  
  <pre><code>tbl_users newUser = new tbl_users() //assume inputted values to new ibject
  {
      userName = this.WinWorkers_AddEditWorkers_Form_UserName.Text,
      userPassword = this.WinWorkers_AddEditWorkers_Form_Password.Text,
      userAccessLevel = this.WinWorkers_AddEditWorkers_Form_UserAccessLevel.Text
  };
  
  //default minimal password length is 4
  if (App.IsInputValueMinLenOK(newUser.userPassword, 4))
  {
      EntityKey key = App.glidusContext.CreateEntityKey("tbl_users", objToBeEdited);
  
      if (App.glidusContext.TryGetObjectByKey(key, out objToBeEdited))
      {
          App.glidusContext.ApplyCurrentValues&lt;tbl_users&gt;(key.EntitySetName, newUser);
      }
  
      try
      {
          App.glidusContext.SaveChanges();
      }
      catch (Exception ex)
      {
          App.UnitedHandleException(ex);
      }
  </code></pre>
  
  <p>Please, help me, how to implement update ADO.NET record from the database.</p>
  
  <p>For example, in my table there is <em>James Bond 007</em>, after editing page (clicking in submit page) I see <em>Austin Powers 008</em>.</p>