0
votes

I'm using breeze + EF as part of my asp.net mvc 4 project spa.

When creating an entity with primary key which is set by the user (not defined as identity or computed), the user must set this key in the client.

After editing existing entity by changing the value of that entity key in the client and saving changes: the request is transmitted successfully, the server breeze controller executes savebundle and everything seems to behave as expacted. Yet the change is not saved to the database (using sql profiles shows that no sql statement is being called). Performing the same process while changing property value that is not part of the key works as expected. Does anyone had such an issue?

Thanks,
Eran

1

1 Answers

1
votes

Changing the key of an existing entity ( one already attached to an EntityManager) with Breeze is a bad idea. Breeze should probably throw an exception in this case, ( and I've just added an internal bug item for this). The reason is that from an 'entity' perspective this is actually two operations combined. ( an insert and a delete).

As a point of reference, this kind of operation is explicitly prohibited within the Entity Framework.

To create the same effect you will need to first delete the current entity and then insert a new entity with the same key.