title: How to configure a foreign key on an owned EF entity's property?
body: <p><strong>EF Core 3.0</strong></p>
  
  <p>I have the following (simplified) entities in my domain: </p>
  
  <pre><code>class ApplicationUser {
      public int Id { get; set; }
      public string UserName { get; set; }
      // other properties
  }
  
  [Owned]
  class Stamp {
      public string Username { get; set; }
      public ApplicationUser User { get; set; }
      DateTime DateTime { get; set; }
  }
  
  class Activity {
      public Stamp Created { get; set; }
      public Stamp Modified { get; set; }
      // other properties
  }
  </code></pre>
  
  <p>It's not particularly relevant, but it's worth mentioning that <code>ApplicationUser.UserName</code> is a non-primary, unique key. (<code>ApplicationUser</code> actually inherits from ASP.NET <code>IdentityUser</code>.)</p>
  
  <p>I want to enforce that <code>Stamp.Username</code> is a foreign key referencing <code>ApplicationUser.UserName</code>. </p>
  
  <p>If <code>Stamp</code> was a regular, <em>non-owned</em> entity, this would have set up that relationship:</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      base.OnModelCreating(modelBuilder);
  
      // Stamp.Username =&gt; ApplicationUser.UserName
      modelBuilder.Entity&lt;Stamp&gt;(e =&gt; {
          e.HasOne(s =&gt; s.User)
          .WithOne()
          .HasForeignKey&lt;Stamp&gt;(s =&gt; s.Username)
          .HasPrincipalKey&lt;ApplicationUser&gt;(u =&gt; u.UserName);
      });
      ...
  }
  </code></pre>
  
  <p>When I try to create a migration (<code>dotnet ef migrations add</code>) I get an <code>InvalidOperationException</code> saying "The type 'Stamp' cannot be configured as non-owned because an owned entity type with the same name already exists". </p>
  
  <p>How to achieve what I'm trying to do, using Fluent API or otherwise?</p>