[Resolved] – EntityState must be set to null, Created (for Create message) or Changed (for Update message)
Views (5515)
Recently I was facing an issue with Update of a record in the Plugin. The error message was as ‘EntityState must be set to null, Created (for Create message) or Changed (for Update message)’.
The plugin was written on Post-Operation of Create action.
After looking for the resolution for the issue, I came across a solution posted online, which I am not sure, is supported, but worked for me.
Before calling the _service.Update(Entity), You need to change the state of entity as below:
recordToUpdate.EntityState = EntityState.Changed;
Hope this helps.
Also there is another approach to resolve this:
Instead of using
context.Update(object),
Use:
context.UpdateObject(object)
Reference:

This was originally posted here.
*This post is locked for comments