title: Is it possible to capture a 0..1 to 0..1 relationship in Entity Framework?
body: <p>Is there a way to make a nullable reverse navigation property for a nullable Foreign Key relationship in Entity Framework? In database parlance, a <strong>0..1 to 0..1</strong> relationship. </p>
  
  <p>I've tried as below, but I keep getting the error message:</p>
  
  <blockquote>
    <p>Unable to determine the principal end of an association between the types 'Type1' and 'Type2'. 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 Type1 {
  
      public int ID { get; set; }
  
      public int? Type2ID { get; set; }
      public Type2 Type2 { get; set; }
  }
  
  public class Type2 {
  
      public int ID { get; set; }
  
      public int? Type1ID { get; set; }
      public Type1 Type1 { get; set; }
  }
  </code></pre>
  
  <p>I understand that the integer column can only exist in one table or the other, but surely it should be possible to cover all necessary cases? E.g:</p>
  
  <pre><code>Type1      Type2
  ========   ===============
  ID         ID   | Type1ID
  --------   ---------------
  1          1    | null
  2          2    | 2
  </code></pre>
  
  <p>I've tried using data annotations (e.g. <code>[ForeignKey]</code> on one end, <code>[InverseProperty]</code> on both), but none of those seem to help the matter.</p>
  
  <p>If possible, a data annotation solution would be preferred over Fluent API. Also, the <code>int?</code>  property isn't strictly necessary from a domain perspective for either class, if that helps.</p>
  
  <p>There is an interesting work-around <a href="https://stackoverflow.com/a/13209081/832136">here</a> which implies it isn't possible to capture this kind of relationship in Entity Framework (effectively, an item that is optionally part of a collection) - if so, is there any documentation that would support this?.</p>