title: Entity Framework The Include path expression must refer to a navigation property defined on the type
body: <p>I have this classes:</p>
  
  <pre><code>public class Activity
  {
      public int Key { set; get; }
      public virtual ICollection&lt;Tag&gt; Tags { set; get; }
  }
  
  public class Hobby : Activity
      {
          public int SectionId { set; get; }
          public Section Section { set; get; }
      }
  
  public class Location : Activity
      {
          public int StudioId { set; get; }
          public virtual Studio Studio{get;set;}
      }
  
  public class Tag
      {
          public int Key { set; get; }
          public string Name { set; get; }
          public bool Valid { set; get; }
  
          public Tag()
          {
              this.Activities = new List&lt;Activity&gt;();
          }
  
          public virtual ICollection&lt;Activity&gt; Activities { set; get; }
      }
  </code></pre>
  
  <p>Between the Tag and the Activity there is a many to many relationship:</p>
  
  <pre><code>modelBuilder.Entity&lt;Activity&gt;().
                HasMany(c =&gt; c.Tags).
                WithMany(p =&gt; p.Activities).
                Map(
                 m =&gt;
                 {
                     m.MapLeftKey("ActivityId");
                     m.MapRightKey("TagId");
                     m.ToTable("Pointer");
                 });
  </code></pre>
  
  <p>Now in my controller i'm trying to do this: For each tag to get all the activities pointed by him and for each activity to get: the studio(in case the activity is a location) / the section(in case the activity is a hobby). To do this i firs have to tell EF that it has to lazy-load some objects in relation with the tag. I tried to do something like this:</p>
  
  <pre><code>public IEnumerable&lt;Tag&gt; GetTags()
          {
              using (WelcomolidayDbContext db = new WelcomolidayDbContext())
              {
                  return db.Tags
                      .Include("Activities")
                      .Include(t =&gt; t.Activities.Select(a =&gt; a.Creator))
                      .Include(t =&gt; t.Activities.Select(a =&gt; a.Pictures))
                      .Include(t =&gt; t.Activities.OfType&lt;Hobby&gt;().Select(a=&gt;a.Section))
                      .Include(t =&gt; t.Activities.Select(a =&gt; a.Pictures))
                      .Include(t =&gt; t.Activities.OfType&lt;Location&gt;().Select(a =&gt; a.Studio))
                      .Include(t =&gt; t.Activities.Select(a =&gt; a.Tags)).ToList();
              }
          }
  </code></pre>
  
  <p>But i get the error:</p>
  
  <pre><code>   The Include path expression must refer to a navigation property defined on the type. 
  Use dotted paths for reference navigation properties and the Select operator for 
  collection navigation properties.Parameter name: path
  </code></pre>
  
  <p>Does anybody know what i am doing wrong, or if there is a way around this?
  Thanks.</p>
  
  <p>Alexandru.</p>