title: An object with a key that matches the key of the supplied object could not be found in the ObjectStateManager
body: <p>I want to update record from <code>FormView</code> with <code>ObjectDataSource</code> and lose my day to solve this error.</p>
  
  <blockquote>
    <p>An object with a key that matches the key of the supplied object could
    not be found in the ObjectStateManager. Verify that the key values of
    the supplied object match the key values of the object to which
    changes must be applied.</p>
  </blockquote>
  
  <p>My code is below</p>
  
  <pre><code>private static Entities1 _db = null;
  
  public static Entities1 CreateDataContext()
  {
      if (_db == null)
      {
          _db = new Entities1(System.Configuration.ConfigurationManager.ConnectionStrings["Entities1"].ConnectionString);
          _db.games.MergeOption = MergeOption.NoTracking;
          _db.my_aspnet_users.MergeOption = MergeOption.NoTracking;
          _db.platforms.MergeOption = MergeOption.NoTracking;
      }
      return _db;
  }
  
  public void Update(game item)
  {
      Entities1 DB = CreateDataContext();
      item.modified = DateTime.Now;
      var obj = (from u in DB.games
                 where u.idgames == item.idgames
                 select u).First();
      DB.games.ApplyCurrentValues(item);//Error Here
      DB.SaveChanges();         
  }
  </code></pre>