title: EF -- Unable to determine the principal end of an association between the types
body: <p>I'm having trouble working out what I am doing wrong here. I'm using asp.net Identity and I have created a new entity called <code>Person</code>. I updated the <code>ApplicationUser</code> Class to have a reference to the <code>Person</code>. I wanted to create a navigation property from <code>Person</code> to <code>User</code>. But when I execute the Update-Database I keep getting an error message </p>
  
  <blockquote>
    <p>Unable to determine the principal end of an association between the types 'myapp.Models.ApplicationUser' and 'myapp.Models.DataModels.Person'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.</p>
  </blockquote>
  
  <pre><code>public class Person 
  {
      public Guid ID {get; set;}
      ...
      public virtual ApplicationUser user {get; set;}
  }
  
  public class ApplicationUser
  {
      ...
      public Person person {get; set;}
  }
  </code></pre>
  
  <p>In the code, I'm doing the following</p>
  
  <pre><code>ApplicationUser user = new ApplicationUser {...} 
  
  Person person = new Person {....} 
  user.person = person;
  </code></pre>
  
  <p>I'm also wondering whether I need to set anything for the Virtual property of <code>Person</code> such <code>person.user = user</code>;</p>
  
  <p>I've tried to follow this <a href="https://stackoverflow.com/questions/16842363/unable-to-determine-the-principal-end-of-an-association-between-the-types">Unable to determine the principal end of an association between the types</a> by doing the following on the virtual property:</p>
  
  <pre><code>public class Person 
  {
      public Guid ID {get; set;}
      ...
      [ForeignKey("ID")]        
      public virtual ApplicationUser user {get; set;}
  }
  </code></pre>
  
  <p>Thanks</p>