Here is how I've defined Blog and Posts in my EF Core 2 project in Visual Studio:
public class BloggingContext : DbContext
{
public DbSet<Blog> Blog { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnConfiguring (DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer (@"Server=.;Database=BlogTest;Trusted_Connection=True;");
optionsBuilder.EnableSensitiveDataLogging ();
}
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public virtual List<Post> Posts { get; set; }
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public virtual Blog Blog { get; set; }
}
Comments
Blog.Take (100).Include (b => b.Posts).ThenInclude (p => p.Blog)
Just as with Visual Studio, you won't see the ThenInclude method appear in the autocompletion listing due to a bug in Roslyn, although it compiles and runs correctly. See https://docs.microsoft.com/en-us/ef/core/querying/related-data for details.
Here is how I've defined Blog and Posts in my EF Core 2 project in Visual Studio: Can you try the same?