0
我有类可能是这样的:Fluent API - 如何映射自定义关系表?
public class Group
{
public int Id {get; set;}
public ICollection<Group> IsMemberOf {get; set;}
}
组可以是其他组的成员。 Id db我有表组和表GroupGroup。在模型构建器中,我使用此代码来定义映射。
modelBuilder.Entity<GroupGroup>()
.ToTable("GroupGroup")
.HasKey(e => new { e.GroupId, e.MemberGroupId });
modelBuilder.Entity<Group>()
.ToTable("Group")
.Ignore(e => e.IsMemberOf);
那么,我的问题是如何将关系表GroupGroup中的组映射到属性IsMemberOf与Fluent API?我对ef,Fluent API等都很陌生,我知道我应该让ef来创建它自己的关系表,但是我必须使用这种方式,因为它连接到AD和其他系统。有什么办法实现这一点?
非常感谢任何提示。