How do I make an Auto Relationship with EF Core 2.2?
I found a link that teaches how to do with EF, but in EF it 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);