title: Entity framework Core set unique one to one relation
body: <p>I have 2 models which must be one to one relation</p>
  
  <pre><code>public class Reference
  {
      public int Id {get;set;}
      public string Name {get;set;}
  }
  
  public class Matrix
  {
      public int Id {get;set;}
      public string Name {get;set;}
      public int ReferenceId {get;set;}
      public Reference Reference {get;set; }
  }
  </code></pre>
  
  <p>One Matrix can only have one Reference and One Reference can only have one Matrix</p>
  
  <p>Here is the problem, the Reference can exist without a Matrix, ReferenceId must be unique on the Matrix</p>
  
  <p>How can i do this besides making the foreign key nullable but still unique?</p>