title: AspNetUsers' ID as Foreign key in separate table, one-to-one relationship
body: <p>I have looked up and down, tried all the different and various ways of being able to store a foreign key of the AspNetUser table in a separate Customer table. I'm still new at ASP.NET and the Entity Framework, but I've read quite a few posts and documentations.</p>
  
  <p>Currently this is what I have</p>
  
  <p>MODELS</p>
  
  <pre><code>public class Customer
  {
      [Display (Name="Customer ID")]
      public int CustomerID { get; set; }
  
      public string UserId { get; set; }
      [ForeignKey("UserId")]
      public virtual ApplicationUser ApplicationUser { get; set; }
  
  }
  
  
   public class ApplicationUser : IdentityUser
  {
      public virtual Customer Customer { get; set; }
  }
  
  public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public DbSet&lt;Customer&gt; Customers { get; set; }
  
      public ApplicationDbContext()
          : base("DefaultConnection")
      {
      }
  
  }
  </code></pre>
  
  <p>I get this error, quote</p>
  
  <blockquote>
    <p>Unable to determine the principal end of an association between the types 'TestApplication.Models.Customer' and 'TestApplication.Models.ApplicationUser'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.</p>
  </blockquote>
  
  <p>I also tried this person's method found here: <a href="https://stackoverflow.com/questions/17254724/the-principal-end-of-this-association-must-be-explicitly-configured-using-either">The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations</a></p>
  
  <p>So I commented out the ForeignKey annotations and used the person's suggestion, using the "modelBuilder" approach. And when I updated my database, the 'Id' from the AspNetUsers table was in the Customers table (which is good), but the CustomerID as a ForeignKey was also in the AspNetUsers table, which is not what I want.</p>
  
  <p>What I want, is the AspNetUsers' 'Id' to be in the Customers table as a ForeignKey.</p>