title: EF Code First 1 to 1 mapping using Fluent API
body: <blockquote>
    <p><strong>How am I going to create the mapping using fluent API if the database architecture is something like this?</strong></p>
  </blockquote>
  
  <pre><code>public class Users 
  {
      public Users() 
      {            
          PermanentAddresses = new PermanentAddresses();
          TemporaryAddresses = new TemporaryAddresses();
      }
      public int Id { get; set; }
      public string LastName { get; set; }
      public string FirstName { get; set; }   
      public virtual PermanentAddresses PermanentAddresses { get; set; }
      public virtual TemporaryAddresses TemporaryAddresses { get; set; }
  } 
  
  public class PermanentAddresses 
  {
      // Primary Key and Foreign Key from Users class
      public string Id { get; set; }
      // Primary Key and Foreign Key from Addresses class
      public int AddressId { get; set; }
      public virtual Users Users { get; set; }
      public virtual Addresses Addresses { get; set; }
  }
  
  public class TemporaryAddresses 
  {
      // Primary Key and Foreign Key from Users class
      public string Id { get; set; }
      // Primary Key and Foreign Key from Addresses class
      public int AddressId { get; set; }
      public virtual Users Users { get; set; }
      public virtual Addresses Addresses { get; set; }
  }
  
  public class Addresses
  {
      public Addresses()
      {
          PermanentAddresses = new PermanentAddresses();
          TemporaryAddresses = new TemporaryAddresses();
          Company = new Company();
      }
      public int Id { get; set; }    
      public string CompleteAddress { get; set; } 
      public virtual PermanentAddresses PermanentAddresses { get; set; }
      public virtual TemporaryAddresses TemporaryAddresses { get; set; }
      public virtual Company Company { get; set; }
  }   
  </code></pre>
  
  <p>I am getting this error.</p>
  
  <p>Unable to determine the principal end of an association between the types 'PermanentAddresses' and 'Addresses'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.</p>