If you are using the Entity Framework, and I assume that you have since you indicated it as a tag in your question, then objects only track their changes when they are created by the entity context.
User someUser = dbEntities.Users.Single(x => x.Username == "test"); someUser.Name = "changed name"; db.SaveChanges();
This code will detect the changes and save them.
User someUser = new User() { Username = "test" //assuming there is already user called test in the database. }
Creating a user this way will not allow the EF context to detect changes. Instead, you will need to load the object from the database, update it, and then save the changes.
string username = "test"; User someUser = db.Users.Single(x => x.Username == username); TryUpdateModel(someUser, valueProvider);
This will allow you to pull out the entity, update it, and save the changes.
source share