Weekly Concepts

Interactive deep dives into the concepts we cover each week

Select a week

EF Core Navigation & API Return Types

Deep dive into Entity Framework Core navigation properties, API return types, and collection interfaces

March 2026

Topics

Navigation Properties in EF Core

Understanding how to define and use navigation properties to represent relationships between entities

Key Points

  • Navigation properties allow you to navigate from one entity to related entities
  • Can be collection navigation properties (one-to-many) or reference navigation properties (one-to-one, many-to-one)
  • EF Core uses navigation properties to understand relationships and generate proper foreign keys
  • Lazy loading, eager loading, and explicit loading control when related data is retrieved

Interactive Code Examples

public class Blog
{
    public int BlogId { get; set; }
    public string Name { get; set; }
    
    // Collection navigation property
    public ICollection<Post> Posts { get; set; }
}

public class Post
{
    public int PostId { get; set; }
    public string Title { get; set; }
    public int BlogId { get; set; }
    
    // Reference navigation property
    public Blog Blog { get; set; }
}

💡 Explanation: A Blog has many Posts (collection navigation), and each Post belongs to one Blog (reference navigation). EF Core will automatically create the BlogId foreign key.