我正在使用 EntityTypeConfiguration 来映射我的数据库。
问题是,类 T_DOC_GENERIC 继承了 T_DOC,当我设置我的 WithMany 关系时,他期望一个对象 T_DOC_GENERIC,他将其声明为 T_DOC。
public class T_DOC_GENERICMapper : EntityTypeConfiguration<T_DOC_GENERIC>
{
T_DOC_GENERICMapper()
{
this.ToTable("T_DOC");
this.HasKey(tDoc => tDoc.ID);
this.HasOptional(tDoc => tDoc.T_TYPE)
.WithMany(tType => tType.T_DOC)
.HasForeignKey(tDoc => tDoc.COD_TYPE);
}
}
无法将类型“System.Collections.Generic.ICollection<Protocol.Models.BaseEntities.T_DOC>”隐式转换为“System.Collections.Generic.ICollection<Protocol.Models.BaseEntities.GenericsEntities.T_DOC_GENERIC>”。存在显式转换(您是否缺少演员表?) D:\PortalProtocolo\Models\Mappers\GenericsMappers\T_DOC_GENERIC.cs
有一种方法可以在 lambda 表达式中进行转换吗?
我尝试了像 .WithMany((T_DOC)tType => tType.T_DOC) 这样的显式转换,但我不知道怎么做!
有人可以帮助我吗?