title: Cannot add FK using EntityFramework
body: <p>I'm learning <code>ASP.NET Core</code> with <code>Entity Framework</code> and I'm trying to add an <code>FK</code> in my <code>UserDetails</code> table. These are the model:</p>
  
  <pre><code>public class User
  {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
  
      public virtual UserDetails UserDetail { get; set; }
  }
  
  public class UserDetails
  {
      public string UserId { get; set; }
      public string Biography { get; set; }
      public string Country { get; set; }
      public Uri FacebookLink { get; set; }
      public Uri TwitterLink { get; set; }
      public Uri SkypeLink { get; set; }
  
      public virtual User UserKey { get; set; }
  }
  </code></pre>
  
  <p>The table <code>User</code> is the <code>Master</code> table which contains all the registered user in my application (I'm using AspNetCore.Identity).</p>
  
  <p>Actual I want add as <code>FK</code> the property <code>UserId</code> which must bound the <code>Id</code> of <code>User</code>. So inside the <code>ApplicationContext</code> class I did the following:</p>
  
  <pre><code>public class DemoAppContext : IdentityDbContext&lt;ApplicationUser&gt;
  {
     public DemoAppContext(DbContextOptions&lt;DemoAppContext&gt; options) : base(options)
     {
     }
  
     protected override void OnModelCreating(ModelBuilder builder)
     {
         builder.Entity&lt;UserDetails&gt;(entity =&gt;
         {
             entity.Property(e =&gt; e.Biography).HasMaxLength(150);
  
             entity.Property(e =&gt; e.Country).HasMaxLength(10);
  
             entity.HasOne(d =&gt; d.UserKey)
                   .WithOne(p =&gt; p.UserDetail)
                   .HasForeignKey(d =&gt; d.???; &lt;- problem here
         });
     }
  
     public DbSet&lt;User&gt; Users { get; set; }
     public DbSet&lt;UserDetails&gt; UserDetails { get; set; }
  }
  </code></pre>
  
  <p>I overrided the <code>OnModelCreating</code> and using the <code>ModelBuilder</code> I defined for <code>UserDetails</code> table the <code>MaxLength</code> of some properties. In the last line of <code>builder.Entity&lt;UserDetails&gt;</code> I tried to assign the <code>FK</code> creating the relationship with <code>HasOne =&gt; UserKey</code> which contains the object <code>User</code>. The relationship is <code>1 to 1</code> so I used <code>WithOne</code> and assigned <code>UserDetail</code> which contains the <code>UserDetails</code> object. </p>
  
  <p>At the end I used <code>HasForeignKey</code> but when I type <code>d.</code> the compiler doesn't show any properties.</p>
  
  <p>What I did wrong? Maybe I overcomplicated the things?</p>
  
  <p>Sorry for any errors, and thanks in advance for any explanation.</p>