I have the following update method in my shared repository
public class Repository<T> : IRepository<T> where T : class { private readonly DbSet<T> _dbSet; public virtual T Update(T item) { return _dbSet.Attach(item); } }
UnitOfWork has a commit method that calls SaveChanges in context. More here
https://codereview.stackexchange.com/questions/19037/entity-framework-generic-repository-pattern
When I update an object and then call
ProductRepository.Update(modifiedProduct); UnitOfWork.Commit;
Nothing floats in the database.
However, just calling Commit operations (no update method call).
So, what does the Attach method do, which leads to the fact that the changes will not go into the database. I think the attach call is the right call to make in the update method. So what causes unexpected behavior.
From EF source code to CodePlex
source share