Moved Entity id assignment to Entity