Répondre

2

comme ceci:

Modèle Classe:

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; } 
} 

Cartographie:

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