Beginning of entitymanager