Set entity's id when adding it.