title: configuring one to one relationship in asp.net identity
body: <p>this is my ApplicationUser class.I have added only one new property ----</p>
  
  <pre><code>   public class ApplicationUser : IdentityUser
     {
      //public ApplicationUser()
      //{
      //    UserProfileInfo = new UserProfileInfo { ImageSize = 0, FileName = null, ImageData = 0 };
      //}
      public string HomeTown { get; set; }
      public virtual UserProfileInfo UserProfileInfo { get; set; }
  </code></pre>
  
  <p>and this is my userProfileInfo class where i want to save every user's profile pic after they have completed the registration----</p>
  
  <pre><code>  public class UserProfileInfo
    { 
     // [Key, ForeignKey("ApplicationUser")]
      [Key]
      public int Id { get; set; }
      public int ImageSize { get; set; }
      public string FileName { get; set; }
      public byte[] ImageData { get; set; }
  
     [ForeignKey("Id")]
      public virtual ApplicationUser ApplicationUser { get; set; }
  }
  </code></pre>
  
  <p>and this is my DbContext class -----</p>
  
  <pre><code>    public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
      {
      public ApplicationDbContext()
          : base("DefaultConnection")
      {
      }
  
      public DbSet&lt;UserProfileInfo&gt; UserProfileInfo { get; set; }
  </code></pre>
  
  <p>Now, the problem is that i am unable to configure one to one relationship between ApplicationUser class and UserProfileInfo class.I have tried various ways to do it and followed some stack overflow questions previosly asked But after i had completed my registration form, it states error------</p>
  
  <p><strong>Unable to determine the principal end of an association between the types 'CodeFirstContext.ApplicationUser' and 'CodeFirstContext.UserProfileInfo'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.</strong></p>
  
  <p>i have also tried to put relationship with the help of fluent api-----</p>
  
  <pre><code>    protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
         // base.OnModelCreating(modelBuilder);
  
          //// Configure Id as PK for UserProfileInfo class
          modelBuilder.Entity&lt;UserProfileInfo&gt;()
              .HasKey(e =&gt; e.Id);
  
          // Configure Id as FK for UserProfileInfo
          modelBuilder.Entity&lt;ApplicationUser&gt;()
              .HasOptional(s =&gt; s.UserProfileInfo)
              .WithRequired(ad =&gt; ad.ApplicationUser);
      }
  </code></pre>
  
  <p>This way i also failed.Please suggest me how to configure it.</p>