Entity framework EF 4.3 fluent映射中间表TPT

Entity framework EF 4.3 fluent映射中间表TPT,entity-framework,fluent,entity-framework-4.3,Entity Framework,Fluent,Entity Framework 4.3,我有以下传统的表结构(简化了此帖子) 以下是我对配置实体的微弱尝试: public class EntityConfiguration : EntityTypeConfiguration<Entity> { public EntityConfiguration() { ToTable("Entity"); HasKey(x => x.Id); Property(x => x.Id) .HasDatabaseGeneratedOption(Databa

我有以下传统的表结构(简化了此帖子)

以下是我对配置实体的微弱尝试:

public class EntityConfiguration : EntityTypeConfiguration<Entity> {
public EntityConfiguration() {
  ToTable("Entity");
  HasKey(x => x.Id);
  Property(x => x.Id)
    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

  HasMany(x => x.TypeOneUpdateBlacklist)
    .WithMany()
    .Map(x => {
      x.ToTable("UpdateBlacklist");
      x.MapLeftKey("EntityId");
      x.MapRightKey("UpdateId");
    });

  HasMany(x => x.TypeTwoUpdateBlacklist)
    .WithMany()
    .Map(x => {
      x.ToTable("UpdateBlacklist");
      x.MapLeftKey("EntityId");
      x.MapRightKey("UpdateId");
    });
}
公共类EntityConfiguration:EntityTypeConfiguration{
公共实体配置(){
可转让(“实体”);
HasKey(x=>x.Id);
属性(x=>x.Id)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
HasMany(x=>x.TypeOneUpdateBlakList)
.有很多
.Map(x=>{
x、 ToTable(“UpdateBlakList”);
x、 MapLeftKey(“实体ID”);
x、 MapRightKey(“更新ID”);
});
HasMany(x=>x.typeTwoUpdateBlakList)
.有很多
.Map(x=>{
x、 ToTable(“UpdateBlakList”);
x、 MapLeftKey(“实体ID”);
x、 MapRightKey(“更新ID”);
});
}
配置显示此错误:

已定义具有架构“dbo”和表“UpdateBlacklist”的EntitySet“EntityBlacklistUpdate”。每个EntitySet必须引用唯一的架构和表。


是否需要配置此功能?请提前感谢

您应该能够使用基本类型
Update
创建多对多映射:

public class EntityConfiguration : EntityTypeConfiguration<Entity> {
    public EntityConfiguration() {
    ToTable("Entity");
    HasKey(x => x.Id);
    Property(x => x.Id)
        .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

    HasMany(x => x.Updates)
        .WithMany()
        .Map(x => {
            x.ToTable("UpdateBlacklist");
            x.MapLeftKey("EntityId");
            x.MapRightKey("UpdateId");
    });
}
公共类EntityConfiguration:EntityTypeConfiguration{
公共实体配置(){
可转让(“实体”);
HasKey(x=>x.Id);
属性(x=>x.Id)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
有很多(x=>x.Updates)
.有很多
.Map(x=>{
x、 ToTable(“UpdateBlakList”);
x、 MapLeftKey(“实体ID”);
x、 MapRightKey(“更新ID”);
});
}

但是,这将要求您的类
实体
只具有基本类型的导航集合
更新
,而不是两个派生类型的导航集合。并且只有在数据库架构真正表示继承模型时才可能,即给定的
更新
行可以具有相关的
TypeOneUpdate
TypeTwoUpdate
行,两者都不能同时存在。如果两者都存在,则无法将其映射到TPT,但必须创建一对一的关系。

这似乎是不可能的。我能想到的唯一可行的解决方案是两个不同的表TypeOneUpdateBlacklist和TypeTwoUpdateBlac克莱斯特。