title: How to Eager Load associated data in EF Core?
body: <p>I have a Gig Model as follows:</p>
  
  <pre><code>public class Gig
  {
      public int Id { get; set; }
  
      [Required]
      public ApplicationUser Artist { get; set; }
  
      [Required]
      public string ArtistId { get; set; }
  
      public DateTime DateTime { get; set; }
  
      [Required]
      [StringLength(255)]
      public string Venue { get; set; }
  
      [Required]
      public Genre Genre { get; set; }
  
      [Required]
      public byte GenreId { get; set; }
  }
  </code></pre>
  
  <p>In EF6, I was able to Eager Load <strong>Artist</strong> and <strong>Genre</strong> using the following code</p>
  
  <pre><code>            var gigs = _context.Attendances
              .Where(a =&gt; a.AttendeeId == userId)
              .Select(a =&gt; a.Gig)
              .Include(a =&gt; a.Artist)
              .Include(a =&gt; a.Genre)
              .ToList();
  </code></pre>
  
  <p>But with EF Core, the Artist info or the Genre info is not getting loaded. SQL Profiler shows that there is no INNER JOIN being called on the projection tables.</p>
  
  <pre><code>SELECT [a.Gig].[Id], [a.Gig].[ArtistId], [a.Gig].[DateTime], [a.Gig].[GenreId], [a.Gig].[Venue]
  FROM [Attendances] AS [a]
  INNER JOIN [Gigs] AS [a.Gig] ON [a].[GigId] = [a.Gig].[Id]
  WHERE [a].[AttendeeId] = @__userId_0',N'@__userId_0 nvarchar(450)',@__userId_0=N'469d8515-9a04-46af-9276-09c6fead9e10'
  </code></pre>
  
  <p>Can someone help me re-write the query for EF Core please to include the projection tables?</p>
  
  <p><a href="https://i.stack.imgur.com/PMKqn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PMKqn.png" alt="eager load"></a></p>
  
  <p>UPDATE:
  added link to db schema scripts <a href="http://www.filedropper.com/gigsissuestackoverflow" rel="nofollow noreferrer">here</a>. posting just the gigs table here:</p>
  
  <pre><code>CREATE TABLE [dbo].[Gigs](
      [Id] [int] IDENTITY(1,1) NOT NULL,
      [ArtistId] [nvarchar](450) NOT NULL,
      [DateTime] [datetime2](7) NOT NULL,
      [GenreId] [tinyint] NOT NULL,
      [Venue] [nvarchar](255) NOT NULL,
   CONSTRAINT [PK_Gigs] PRIMARY KEY CLUSTERED 
  (
      [Id] ASC
  )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  
  GO
  ALTER TABLE [dbo].[Attendances]  WITH CHECK ADD  CONSTRAINT [FK_Attendances_AspNetUsers_AttendeeId] FOREIGN KEY([AttendeeId])
  REFERENCES [dbo].[AspNetUsers] ([Id])
  GO
  ALTER TABLE [dbo].[Attendances] CHECK CONSTRAINT [FK_Attendances_AspNetUsers_AttendeeId]
  GO
  ALTER TABLE [dbo].[Attendances]  WITH CHECK ADD  CONSTRAINT [FK_Attendances_Gigs_GigId] FOREIGN KEY([GigId])
  REFERENCES [dbo].[Gigs] ([Id])
  GO
  ALTER TABLE [dbo].[Attendances] CHECK CONSTRAINT [FK_Attendances_Gigs_GigId]
  GO
  ALTER TABLE [dbo].[Gigs]  WITH CHECK ADD  CONSTRAINT [FK_Gigs_AspNetUsers_ArtistId] FOREIGN KEY([ArtistId])
  REFERENCES [dbo].[AspNetUsers] ([Id])
  ON DELETE CASCADE
  GO
  ALTER TABLE [dbo].[Gigs] CHECK CONSTRAINT [FK_Gigs_AspNetUsers_ArtistId]
  GO
  ALTER TABLE [dbo].[Gigs]  WITH CHECK ADD  CONSTRAINT [FK_Gigs_Genres_GenreId] FOREIGN KEY([GenreId])
  REFERENCES [dbo].[Genres] ([Id])
  ON DELETE CASCADE
  GO
  ALTER TABLE [dbo].[Gigs] CHECK CONSTRAINT [FK_Gigs_Genres_GenreId]
  GO
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/j8lWR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j8lWR.png" alt="Table relationships"></a></p>