title: ObjectSet.ApplyCurrentValues v/s StateManager.ChangeObjectState
body: <p>I am quite new to Entity Framework 4.1. I am starting to write a new application using EF as my DAL. I am using POCO classes (using POCO t4 template) with database first approach.</p>
  
  <p>My GenericRepository has got below Update method</p>
  
  <pre><code>public void Update(TEntity entity)
  {
      if (entity == null)
      {
          throw new ArgumentNullException("entity");
      }
  
      _context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
      //_objectSet.ApplyCurrentValues(entity);
  }
  </code></pre>
  
  <p>I having a gridview which is databind to ObjectDataSource having UpdateMethod="UpdateStore" which takes only one parameter is as follows...</p>
  
  <pre><code>public void UpdateStore(Store franchise)
  {
      unitOfWork.StoreRepository.Attach(franchise);
      unitOfWork.StoreRepository.Update(franchise);
      unitOfWork.SaveChanges();
  }
  </code></pre>
  
  <p>I got couple of question here:</p>
  
  <ol>
  <li><p>When I see the documentation for <a href="http://msdn.microsoft.com/en-us/library/bb896271.aspx" rel="nofollow">ApplyCurrentValues</a>, it proves me that I should use this to update values but this doesn't work (as you can see in above commented line). Then when I try with ObjectStateManager.ChangeObjectState, it works. What's the difference between this two approaches.</p></li>
  <li><p>As you can see, I attach first and then apply the update method. Can I combine attach and updating state inside my GenericRepository update method. Is there any pitfall there in doing so?</p></li>
  </ol>