title: EF recursive cte for calculating hierarchy path
body: <p>I have self-referencing table and I want to add computed column for ancestors path such as :</p>
  
  <pre><code>public class PhysicalObject
  {
      public PhysicalObject()
      {
          SubPhysicalObjects = new HashSet&lt;PhysicalObject&gt;();
      }
  
      [Key]
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int Id { get; set; }
  
      public int? ParentId { get; set; }
  
      [StringLength(150)]
      public string Title { get; set; }
  
      public string Path {get; set;}
  
      public virtual PhysicalObject Parent { get; set; }
  
      public virtual ICollection&lt;PhysicalObject&gt; SubPhysicalObjects { get; set; }
  }
  </code></pre>
  
  <p>for example path= "1_50_60"</p>
  
  <p>Here (1,50,60) are the Ids of ancestors to help me for searching trees.</p>
  
  <p>How could I achieve that using Entity framework code first?</p>