EntityManager merge method generate insert call rather than update even though id exist

This is a duplicate of 7150.