I'm having the same problem as described in New Breeze 1.4.9 - Duplicate entity - possible bug?, however that problem was reported as being caused by a bug since fixed. I am using v1.4.11.
I'm finding that when I save a new Breeze entity to the server it reacts to the successful response from the server by creating a new, duplicate entity, instead of updating the existing one. I am running the following test code line-by-line in a browser console, from a state of having no entities in Breeze's cache.
EntityManager.createEntity("CustomGroup", properties);
EntityManager.getChanges(); =>
0:
Id="b0cb3194-35af-4d23-9e77-d192c907b566"
EntityState=Added
So far, so good. As expected there is a single entity in the pending changes array.
EntityManager.saveChanges(); =>
KeyMappings:
0:
TempValue="b0cb3194-35af-4d23-9e77-d192c907b566"
RealValue="f056f519-9f11-4375-a0dd-5272a11b9b46"
After executing saveChanges(), the server returns a KeyMapping object with the temp and real key values. At this point, listing all entities in the cache reveals an unexpected result:
EntityManager.getEntities(); =>
0:
Id="f056f519-9f11-4375-a0dd-5272a11b9b46"
EntityState=Added
1:
Id="b0cb3194-35af-4d23-9e77-d192c907b566"
EntityState=Unchanged
So, while Breeze has changed the state of the original object to "Unchanged" in response to being saved to the server, it has not updated it with the new key, and has instead created a duplicate entity using the new key, which it thinks it still needs to save.
A 2nd call to saveChanges() sends a new request to the server, which responds with a KeyMapping object that has identical TempValue and RealValue, and at this point Breeze decides there are no more changes, although the rogue entity remains in the cache of course.