3
How to Make a Self Relationship with EF Core 2.2?
I found a link that teaches to do with EF, but in EF does not have the Withoptional method.
public class Menu
{
public int Id { get; set; }
public string Title { get; set; }
public int? MenuId { get; set; }
public ICollection<Menu> SubMenu { get; set; }
}
modelBuilder.Entity<Menu>()
.HasMany(x => x.SubMenu)
.WithOptional()
.HasForeignKey(x => x.MenuId);
base.OnModelCreating(modelBuilder);