Is it possible to set parent/child relations using EF Core and fluent api?
I have following class
public class Category
{
public int Id { get; set; }
public int ParentId { get; set; }
public string Name { get; set; }
public ICollection<Category> SubCategories { get; set; }
}
So if I create list of objects with have structure as below, it is possible that, EF set entitie's id, and parentId with appropriate numbers?
- Cat 1
- Cat 2
- Cat 3
- Cat4
- Cat5
- Cat 2