title: Entity Framework lazy loading does not work (foreign key object null)
body: <pre><code>public class Game
  {
      public long Id { get; set; }
      public DateTime Date { get; set; }
      public virtual Team HomeTeam { get; set; }
      public virtual Team AwayTeam { get; set; }
      public virtual Lineup HomeLineup { get; set; } 
      public virtual Lineup AwayLineup { get; set; }
      public int Spectators { get; set; }
      public virtual List&lt;Goal&gt; Goals { get; set; }
  
      public override string ToString()
      {
          return base.ToString();
      }
  }
  </code></pre>
  
  <p>I am trying to query this games table, the foreign keys of the virtual declared attributes gets inserted correctly, but when I try to query the games table, every foreign key object is null, so lazy loading does not seem to work. </p>
  
  <p>HOWEVER on the first start of the application, when I am inserting new data into the database, it does work. When I restart the app the foreign key object are all null, primitive data types are still working.</p>
  
  <p>I am querying like this:</p>
  
  <pre><code>try
  {
      var context = services.GetRequiredService&lt;ManagerContext&gt;();
      DbInitializer.Initialize(context, logger);
      List&lt;Game&gt; games = context.Games.ToList&lt;Game&gt;();
  
      if(games[0] != null)
      {
         GameSimulation.SimulateGame(games[0], logger);
      }
  }
  catch(Exception ex)
  {
      logger.LogError(ex, "Fehler beim Erstellen von Testdaten!");
  }
  </code></pre>