1
votes

In my project I am using Entity framework 6 and Breeze for fetching the data. On client side I am creating a breeze entity in modified state as shown below,

var entity = manager.createEntity(entityName);

entity.entityAspect.setModified();//Modifying the state

entity.Id(id);//pushing existing primary key value

entity.IfInactive(true); //updating the record value from false to true

saveChanges(msg).then(function () { //calling save changes
   console.log('Success.');
});

But during savechanges it is giving an exception like "The original value for the property 'Id' cannot be set because the property is part of the entity's key."

Thanks in Advance!

1

1 Answers

1
votes

You need to use an initializer to set the value of the key when the entity is created:

var entity = manager.createEntity(entityName, { Id: id });