Using 3.1, the key is to make sure the identity value of the object you are updating matches the value of the record in the database. So if your object's ID is 0 but the id of the corresponding row in the database is 99, make sure the object's ID value is set to 99 before you try to save it.