Interactive deep dives into the concepts we cover each week
Deep dive into Entity Framework Core navigation properties, API return types, and collection interfaces
Understanding how to define and use navigation properties to represent relationships between entities
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.