I am able to create an entity object, set some default values and add it to the manager. Now I want to track the changes to it using manager.hasChanges()
. For some reason, this always returns true. Should I be checking something else too when tracking newly created entities that are not in the database?
As soon as you 'Add' it to the EntityManager, by definition, it has changes because it is in an 'Added' state. To breeze 'hasChanges' means that it needs to be saved because it is 'different' from what was provided by your persistence service ( in this case the entity hasn't yet been 'saved').
What you can do is 'Attach' your entity to the EntityManager in an 'Unchanged' state.
myEntityManager.attachEntity(newEntity, breeze.EntityState.Unchanged);
In this case, any changes you make will work the way you want, BUT ...
Breeze will now consider your newly attached entity to already have been persisted and if you try to save it, then the save will fail because breeze will try to 'modify' the persisted entity instead of creating a new one.
If you really want to accomplish your request you will need to use 'attach' but also keep track of these entities and mark them 'added' before you attempt to save them.