Fixed generateEntityId method