title: How can I join two tables by a foreign key table in Entity Framework?
body: <p>I am trying to join two tables by a foreign key table in linq.
  The two tables are
  Items and Classes, and the foreign key table is ItemClasses (ItemId, ClassId).</p>
  
  <p>My context does not have a DBSet for the foreign key table, and when I try to add it I get a model creation error.</p>
  
  <p>When I saw the error, I noticed that this code referred to the foreign key table                 </p>
  
  <pre><code>modelBuilder.Entity&lt;Classes&gt;()
              .HasMany(e =&gt; e.Items)
              .WithMany(e =&gt; e.Classes)
              .Map(m =&gt; m.ToTable("ItemClasses").MapLeftKey("ClassId").MapRightKey("ItemId"));
  </code></pre>
  
  <p>So it looks like I should be able to refer to the items through the class, but how do I join the tables?</p>
  
  <p>I'd like to do something like this</p>
  
  <pre><code>            query = from ig in myCtx.Items.AsNoTracking()                          
                           //join di in myCtx.ItemClasses.AsNoTracking() on ig.Id equals di.ClassId
                           join c in myCtx.Classes.AsNoTracking() on di.ClassId equals c.Id
                           join dd in myCtx.SalesAssociates.AsNoTracking() on dd.Id equals ig.SalesAssociateId
  </code></pre>
  
  <p>How do I do joins when the fk table is not in my context, but is referred to in one of the tables?</p>