답변

2

과 같이 :

모델 클래스 :

public class Entity 
{ 
    public int Id { get; set; } 
    public string Name { get; set; } 

    public ICollection<Entity> Parents { get; set; } 
    public ICollection<Entity> Children { get; set; } 
} 

매핑 :

modelBuilder.Entity<Entity>() 
    .HasMany(e => e.Parents) 
    .WithMany(e => e.Children) 
    .Map(m => 
    { 
     m.ToTable("Member"); 
     m.MapLeftKey("ParentEntityId"); 
     m.MapRightKey("ChildEntityId"); 
    });