title: Entity Framework Core 3.1 One to many relations - Only getting first child entity for parent Fluent API Syntax
body: <p>hoping to get some help with data retrieval using EF Core 3.1. I have two entities that have one-to-many relationships. However, they will be connected by email address which is not a primary key in either of these tables. I did declare a property in the parent entity that holds the ICollection of the child entity, and there is no property declared in the child entity that references the parent since I don't want that.  The problem here is I am always getting the first child entity for the ICollection property, even though I know there are more. Here is the code snippet:</p>
  <p>** Property declared in the parent for the child:</p>
  <pre><code>public virtual ICollection&lt;Contact&gt; Contacts { get; set; }
  </code></pre>
  <p>** Here is the fluent API code in parent entity type configuration:</p>
  <pre><code>    builder.HasMany(e =&gt; e.Contacts)
              .WithOne()//Since child entity doesn't have any property to hold the parent
              .HasPrincipalKey(x =&gt; x.UserName)
              .HasForeignKey(x =&gt; x.EmailAddress);
  </code></pre>
  <p>Here UserName field in the Parent entity is connected with emailaddress field in the child entity.</p>
  <p>** Here is the fetch call:</p>
  <pre><code>public override async Task&lt;List&lt;User&gt;&gt; Fetch(Expression&lt;Func&lt;User, bool&gt;&gt; filter)
  {
  return await _context.Set&lt;User&gt;()
  .AsNoTracking()
  .Where(filter)
  .Include(x =&gt; x.Contacts)    
  .ToListAsync();
  }
  </code></pre>
  <p>This code is always giving me the first child entity, even though I know there are more. What exactly I am doing wrong here. I would really appreciate your help here. Thank you.</p>