title: Entity Framework Many to Many works but Include does not
body: <p>I have a typical many-to-many relationship with these 3 tables</p>
  
  <pre><code>[Post] (
    [PostId] int, (PK)
    [Content] nvarchar(max)
     ...
  )
  
  [Tag] (
    [TagId] int, (PK)
    [Name] nvarchar
    ...
  )
  
  [TagPost] (
    [TagId] int, (PK, FK)
    [PostId] int (PK, FK)
  )
  </code></pre>
  
  <p>And, TagId and PostId are the PK and FK set on the tables accordingly etc.  Then I have these classes and mapping in c#</p>
  
  <pre><code>public class Post {
      public Post()
      {
          this.Tags = new HashSet&lt;Tag&gt;();
      }
  
      [Key]
      public int PostId { get; set; }
      ...
  
      public virtual ICollection&lt;Tag&gt; Tags { get; private set; }
  }
  
  public class Tag {
      public Tag()
      {
          this.Posts = new HashSet&lt;Post&gt;();
      }
  
      [Key]
      public int TagId { get; set; }
      ...
  
      public virtual ICollection&lt;Post&gt; Posts { get; private set; }
  }
  
  internal class MyDbContext : DbContext
  {
      public DbSet&lt;Post&gt; Posts { get; set; }
      public DbSet&lt;Tag&gt; Tags { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
  
          modelBuilder.Entity&lt;Post&gt;().ToTable("Post");
          modelBuilder.Entity&lt;Tag&gt;().ToTable("Tag");
  
          modelBuilder.Entity&lt;Post&gt;()
              .HasMany(x =&gt; x.Tags)
              .WithMany(x =&gt; x.Posts)
          .Map(x =&gt;
          {
              x.ToTable("TagPost");
              x.MapLeftKey("PostId");
              x.MapRightKey("TagId");
          });
      }
  </code></pre>
  
  <p>Then I have this code to query them</p>
  
  <pre><code>var list = (from p in ctx.Posts.Include(p =&gt; p.Tags)
              from t in p.Tags
              where ... // some of my filter conditions
              select p).ToList();
  </code></pre>
  
  <p>This join does return the posts I was looking for, however the returned posts don't their associated tags filled in even though I have the Include there.  Could someone help point out what I'm missing so that I could have the tags also return with the posts?</p>
  
  <p>Thanks a lot.</p>