title: entityframework core - many to many - The property expression is not valid
body: <p><strong>Application Version:</strong></p>
  
  <p>Asp Net Core 1.1</p>
  
  <p>EF: Microsoft.EntityFrameworkCore (1.1.1)</p>
  
  <p><strong>Line:</strong> </p>
  
  <p>_dbContext.MyTable1.Include(c => c.MyIntermediateTable).ThenInclude(k => k.Select(x => x.MyTable2)).ToList();</p>
  
  <p><strong>Exception:</strong></p>
  
  <blockquote>
    <p>The property expression 'k => {from MyIntermediateTable x in k select
    [x].MyTable2}' is not valid. The expression should represent a
    property access: 't => t.MyProperty'. For more information on
    including related data</p>
  </blockquote>
  
  <p><strong>My Entities</strong></p>
  
  <pre><code>[Table("MyTable1")]
  public class MyTable1
  {
      public MyTable1()
      {
          MyIntermediateTable = new List&lt;MyIntermediateTable&gt;();
      }
  
      [Column("MyPK1")]
      public  int MyPK1 { get; set; }
      public  string Name{ get; set; } 
  
      public virtual List&lt;MyIntermediateTable&gt; MyIntermediateTable{ get; set; }
  }
  
  [Table("MyIntermediateTable")]
  public class MyIntermediateTable
  {
  
      public int MyPK1 { get; set; }
      public int MyPK2 { get; set; }
      public virtual MyTable1 MyTable1 { get; set; }
      public virtual MyTable2 MyTable2 { get; set; }
   }
  
  [Table("MyTable2")]
  public class MyTable2
  {
      public MyTable2()
      {
           MyIntermediateTable = new List&lt;MyIntermediateTable&gt;();
      }
  
      [Column("MyPK2")]
      public int MyPK2 { get; set; }
      public  string Name{ get; set; } 
  
      public virtual List&lt;MyIntermediateTable&gt; MyIntermediateTable{ get; set; }
  
  }
  </code></pre>
  
  <p><strong>Model Builder (Fluent API)</strong></p>
  
  <pre><code>       modelBuilder.Entity&lt;MyIntermediateTable&gt;((item) =&gt;
          {
              item.HasKey(p =&gt; new { p.MyPK1, p.MyPK2 });
              item.HasOne(u =&gt; u.MyTable1).WithMany(u =&gt; u.MyIntermediateTable).HasForeignKey(u =&gt; u.MyPK1);
              item.HasOne(u =&gt; u.MyTable2).WithMany(u =&gt; u.MyIntermediateTable).HasForeignKey(u =&gt; u.MyPK2);
          });
  
          modelBuilder.Entity&lt;MyTable1&gt;((item) =&gt;
          {
              item.HasKey(p =&gt; p.MyPK1);
              item.HasMany(u =&gt; u.MyIntermediateTable).WithOne(u =&gt; u.MyTable1).HasForeignKey(u =&gt; u.MyPK1);
          });
  
          modelBuilder.Entity&lt;MyTable2&gt;((item) =&gt;
          {
              item.HasKey(p =&gt; p.MyPK2);
              item.HasMany(u =&gt; u.MyIntermediateTable).WithOne(u =&gt; u.MyTable2).HasForeignKey(u =&gt; u.MyPK2);
          });
  </code></pre>