title: One to one mapping in EF Code First and bi-directional navigation properties
body: <p>I have been tasked with porting an old app to MVC 3, and want to use EF's code first to replicate its existing database schema. The current code base is littered with hard coded SQL commands, and so the model I come up with has to be "compatible" with what the current system expects. I know I could use EF's Database First to do this, but the existing schema is so simple that I see no reason not to use code first, as I want a solid foundation to build on as we migrate away from our old hard-coded database interactions.</p>
  
  <p>What I need the POCOs to look like:</p>
  
  <pre><code>public class Owner
  {
      [Key]
      public Guid Owner_Id { get; set; }
  
      // Properties
      public string ContactName { get; set; }
      public string PhoneNumber { get; set; }
      public string Email { get; set; }
  
      // Navigational properties
      public virtual ICollection&lt;Plant&gt; Plants { get; set; }
  }
  
  public class Plant
  {
      [Key]
      public Guid Plant_Id { get; set; }
  
      // Properties
      public string Address { get; set; }
      public string City { get; set; }
      public string State { get; set; }
      public string Zip { get; set; }
  
      // Foreign Keys
      public Guid Owner_Id { get; set; }
  
      // Navigational properties
      public virtual Owner Owner { get; set; }
      public virtual License License { get; set; }
  }
  
  public class License
  {
      [Key] public Guid License_Id { get; set; }
  
      // Properties
      public int Total { get; set; }
      public int Users { get; set; }
      public string Key { get; set; }
  
      // Foreign Keys
      public Guid Plant_Id { get; set; }
  
      // Navigational properties
      public virtual Plant Plant { get; set; }
  }
  </code></pre>
  
  <p>It's giving me this error on attempting to create the context:</p>
  
  <p>"Unable to determine the principal end of an association between the types 'License' and 'Plant'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations."</p>
  
  <p>I realize that Plant should have a nullable FK reference to a License_Id, and that License shouldn't have a FK for Plant_Id. But these are the cards I have been dealt. Is what I'm trying to do possible in EF?</p>