title: Entity Framework Core Configuration one to zero or one relationship with same primary key
body: <p>In my .NET MVC project, I have my domain classes with one to one or zero relationship as:</p>
  
  <pre><code>public class Person
  {
      public int Id { get; set; }
  
      public string FullName { get; set; }
  
      public Address Address { get; set; }
  }
  
  public class Address
  {
      public string Address { get; set; }
      public string City { get; set; }
  
      public virtual Person Person { get; set; }
      [Key, ForeignKey("Person")]
      public int PID { get; set; }
  }
  </code></pre>
  
  <p>This is using EF 6.x and the Address entity uses PID (which is foreign key) as its identity column. This code is automatically configured in EF 6.x without any explicit configuration.</p>
  
  <p>Now, I am porting this solution to .NET Core 2.1. Here, the EF Core doesn't work with the Data Annotations of EF 6.x. I cannot for example get the property <code>person.Address.City</code> It appears I need to configure it manually using FluentAPI.</p>
  
  <p>So far I have tried three different configs, one after another to no avail:</p>
  
  <pre><code>//First config
         modelBuilder.Entity&lt;Person&gt;()
              .HasOne(p =&gt; p.Address)
              .WithOne(a =&gt; a.Person);
  
  //Second config
          modelBuilder.Entity&lt;Person&gt;()
              .OwnsOne(p =&gt; p.Address);
  
  //Third config
          modelBuilder.Entity&lt;Person&gt;()
              .OwnsOne(p =&gt; p.Address)
              .OwnsOne(a=&gt;a.Person);
  </code></pre>
  
  <p>This project has a lot of data and needs to be configured using the existing entity structure. Please help.</p>