Fix #1111 Updating entity results in error

Fix #1111 Updating entity results in error 'This identifier already exists. It must be unique'