Programmatically get field values of fields added to custom entity
The column for an entity reference field is target_id, so you should just need to replace the getter with:

public function getProjectId() { 
    return $this-&gt;get('project_id')-&gt;target_id; 
}