Hi,
(Code First, EF 4.2.0.0, DF 6.1.6)
Hopefully this code snippet is sufficient to explain.
The UserGroup Entity has these two properties
public class UserGroup : BaseEntity
{
//....
public RelatedEntityList<UserGroup> AllChildren { get { return null; } }
public RelatedEntityList<UserGroup> AllParents { get { return null; } }
The Entity's config is to related them Many to Many
class UserGroupConfiguration : EntityTypeConfiguration<UserGroup>
{
internal UserGroupConfiguration()
{
this.HasMany(i => i.AllChildren)
.WithMany(c => c.AllParents)
.Map(mc =>
{
mc.MapLeftKey("UserGroupId");
mc.MapRightKey("ParentUserGroupId");
mc.ToTable("UserGroupsHierarchy");
});
}
}
Such that it is Many to Many on itself.
Would you expect DF to automatically populate the "UserGroupsHierarchy" linker table
in the same way as a linker table between two different tables does.
It isn't at present!
Thanks
John
Edited by jradxl - 26-Apr-2012 at 5:25pm