title: Realize Entity Framework one-to-one relation
body: <p>I am trying to realize a one-to-one relation in Entity Framework with Code First. I want to create an Airplane table which has a FlightPlan.</p>
  
  <p>Airplane: </p>
  
  <pre><code>public class Airplane
  {
      [Key]
      public int AirplaneId { get; set; }
      public int Capacity { get; set; }
      public AirplaneStatus AirplaneStatus { get; set; }
      public int AmountOfPassengers { get; set; }
      public int AirfieldId { get; set; }
  
      public virtual FlightPlan FlightPlan { get; set; }
  }
  </code></pre>
  
  <p>FlightPlan:</p>
  
  <pre><code>public class FlightPlan
  {
      [Key]
      [ForeignKey("Airplane")]
      public int AirplaneId { get; set; }
      public int AirfieldFrom { get; set; }
      public int AirfieldTo { get; set; }
      public int AmountOfPassengers { get; set; }
  
      public virtual Airplane Airplane { get; set; }
  }
  </code></pre>
  
  <p>When i initialize these classes with Migrations the following table structure is created: </p>
  
  <p><a href="https://i.stack.imgur.com/izXCl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/izXCl.png" alt="enter image description here"></a></p>
  
  <p>After i manage to create an Airplane with a FlightPlan, which takes some workarounds, the Airplane doesn't have a Flightplan no matter what i try.</p>
  
  <p><a href="https://i.stack.imgur.com/D2crp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D2crp.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/mcsrm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mcsrm.png" alt="enter image description here"></a></p>
  
  <p>How can i solve this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>For testing purposes i add a FlightPlan to every updated Airplane. After fixing this a route is created for adding a Flightplan. The code is:</p>
  
  <pre><code>var airplane = _context.Airplanes.Find(model.AirplaneId);
  var flightplan = new FlightPlan() { AirfieldFrom = 1, AirfieldTo = 2, AmountOfPassengers = 30 };
  airplane.FlightPlan = flightplan;
  _context.SaveChanges();
  </code></pre>
  
  <p>The solution for my problem is to force EF to include the FlightPlan when retrieving an Airplane.</p>