title: Entity Framework Join without foreign key
body: <p>I have a messages table which has an id of the user that sent it in each row.
  But I cannot edit the database, and there are no foreign keys.
  Is it possible to join without any relationships?</p>
  
  <pre><code>var msgs = (from m in dbContext.messages
  
                          join a in dbContext.users on m.userid equals a.id into sender
                          where (m.date &gt; LastReceivedDate)
                          orderby m.date
  
                          select new
                          {
                              Sender = sender.FirstOrDefault(),
                              Message = m
                          })
  </code></pre>
  
  <p>Thats my code, and it runs, but never returns anything. When I take the join away I get results.</p>
  
  <p>Thanks</p>