title: Setup one to many relation with fk having multiple rows
body: <p>I have a problem with setting up a one-to-many relation with EF Core.<br />
  I have two tables <code>address</code> and <code>address_country</code>. There are schemas:
  <a href="https://i.stack.imgur.com/FA8AM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FA8AM.png" alt="address table schema" /></a><br />
  <a href="https://i.stack.imgur.com/OMdkz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OMdkz.png" alt="address_country table schema" /></a><br />
  As you see, I want to store countries with different locales. So it has a composed key. <code>address</code> table has a foreign key to <code>address_country</code>. Unfortunately, I cannot setup <code>ContextDb</code> to achieve what I want. The list of countries is not filled in <code>Address</code> model.<br />
  I have the following code in <code>Context</code>:</p>
  <pre><code>public class Context : DbContext
  {
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          optionsBuilder.UseSqlite(
              @&quot;Data Source=addresses.db&quot;);
          base.OnConfiguring(optionsBuilder);
      }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;AddressDto&gt;()
              .ToTable(&quot;address&quot;);
  
          modelBuilder.Entity&lt;CountryLocaleDto&gt;()
              .ToTable(&quot;address_country&quot;);
  
          modelBuilder.Entity&lt;CountryLocaleDto&gt;()
              .HasKey(cl =&gt; new {cl.Id, cl.Locale});
  
          base.OnModelCreating(modelBuilder);
      }
  
      public DbSet&lt;AddressDto&gt; Addresses { get; set; }
  }
  </code></pre>
  <p>And my models are</p>
  <pre><code>public class AddressDto
  {
      public int Id { get; set; }
      public int CountryId { get; set; }
      public List&lt;CountryLocaleDto&gt; CountryLocale { get; set; }
  }
  public class CountryLocaleDto
  {
      public int Id { get; set; }
      public string Locale { get; set; }
  }
  </code></pre>
  <p>There is no exception. I simply don't know how to configure this kind of relation. Can anyone help me with that, please?</p>
  <p>Example data would be:<br />
  <strong>address</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>countryId</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>2</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>address_country</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>locale</th>
  <th>name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>'en'</td>
  <td>'Germany'</td>
  </tr>
  <tr>
  <td>1</td>
  <td>'de'</td>
  <td>'Deutschland'</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>An example solution with SQLite db can be found with <a href="https://github.com/VitaliiIsaenko/ef-core-example-relation" rel="nofollow noreferrer">this link</a>.</p>