public class Employee { [Key, Required] public int Id { get; set; } public int? ManagerId { get; set; } public Employee Manager { get; set; } }
modelBuilder.Entity<Employee>() .HasOptional(r => r.Manager) .WithMany() .HasForeignKey(r => r.ManagerId) .WillCascadeOnDelete(false);