title: Entity Framework Core : Access parent from child
body: <p>Might be a silly question but I'm a bit confused here.</p>
  
  <p>I have a parent entity which contains a list of children.</p>
  
  <pre><code>public class Parent
  {
      public int Id { get; set; }
  
      public List&lt;Child&gt; Children { get; set; }
  }
  
  public class Child
  {
      public int Id { get; set; }
  }
  </code></pre>
  
  <p>EFcore will create a <code>ParentId</code> as a foreign key in the table <code>Child</code>.</p>
  
  <p>Now, let's say I want to retrieve all the children that have a specific Parent, how should I do it ? The <code>ParentId</code> is not available in the <code>Child</code> object.</p>
  
  <p>Therefore, I cannot do something like: </p>
  
  <pre><code>var result = model.Child.Where(child =&gt; child.ParentId == 3);
  </code></pre>
  
  <p>I could add the <code>ParentId</code> property to the child in the entity, but I really don't want this property to be assigned manually. And if I set it as readonly by specifying the getter only, the migration doesn't work anymore.</p>