Merge detached entities.