I have the following EF Code First classes, which appear to be working to a point. I also have Initialization code that seeds these tables with data from elsewhere that is leng
Why SubCategories
is null or with 0 item because you don't include this relation that it is Eager loading. if you want to use lazy loading you can use virtual
keyword in your navigation property:
Lazy Loading:
public virtual List<SubCategory> SubCategories { get; set; }
Eager Loading:
db.Categories.Where(c => c.CategoryCode == "FUND").Include(x => x.SubCategories ).ToList();
Read More.