title: ef core - two one to one on one principal key
body: <p>Got the following datamodel:</p>
  
  <pre><code>class EntityA
  {
      Guid Id { get; set; }
  
      //Property1 and Property2 will never be the same
      EntityB Property1 { get; set; }
      EntityB Property2 { get; set; }
  }
  
  class EntityB
  {
      int Id { get; set; }
  
      EntityA EntityAProperty { get; set; }
  }
  </code></pre>
  
  <p>But I can't manage to configure the relation.
  EntityA references two different EntityB.
  Please give me some advise on how to configure it.</p>
  
  <p>Tried something like (for property1 and property2):</p>
  
  <pre><code>e.HasOne(x =&gt; x.Property1)
                      .WithOne()
                      .HasForeignKey&lt;EntityB&gt;(x =&gt; x.Property1Id)
                      .IsRequired(false);
  </code></pre>
  
  <p>or </p>
  
  <pre><code>e.HasOne(x =&gt; x.Property1)
                      .WithOne(x =&gt; x.EntityB)
                      .HasForeignKey&lt;EntityB&gt;(x =&gt; x.Property1Id)
                      .IsRequired(false);
  </code></pre>
  
  <p>First one tells me that </p>
  
  <blockquote>
    <p>The best match for foreign key properties {'Id' : int} are incompatible with the principal key {'Id' : Guid}.</p>
  </blockquote>
  
  <p>The second one tells me that I can not use the property EntityB for two relations.</p>