title: EF 6 select from other table without navigation property
body: <p>I have a small problem which I need a help to solve:</p>
  
  <p>I have following situation:</p>
  
  <p>For example: I want to select all students who have a dog.</p>
  
  <p>I have 2 tables: </p>
  
  <pre><code>students 
  id name petid
  
  pet
  id name 
  </code></pre>
  
  <p>BUT there is no specified foreign key between them no navigation property, although I have but I haven't specified it and I don't want for my case, but I still want to make a correct select statement.</p>
  
  <p>So with navigation property i could query like this:</p>
  
  <pre><code>var students = (student s in context.students where s.Pet.Name.Equals("dog").ToList();
  </code></pre>
  
  <p>I would avoid doing this also</p>
  
  <pre><code>var students = context.students
  
  foreach(student s in students)
  {
      string pet = (from pet p in context.pets where p.Id==s.PetId select p.name).SingleOrDefault();
       if(pet=="dog")
       { 
           //do something
       } 
  }
  </code></pre>
  
  <p>Of course it would be easy to make navigation property, but for my case I really don't want to.</p>
  
  <p>So my question is how can i do this kind of query simple and with only one to DB?</p>