Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework 4 C#每种类型的实体框架表在基表中添加不需要的列_Entity Framework 4 - Fatal编程技术网

Entity framework 4 C#每种类型的实体框架表在基表中添加不需要的列

Entity framework 4 C#每种类型的实体框架表在基表中添加不需要的列,entity-framework-4,Entity Framework 4,在C#中,我使用实体框架和MVC,并拥有: public class Part public class FinishedGoodsPart: Part public int? ProductLineId { get; set; } public class CompetitorPart : Part public int? ProductLineId { get; set; } public class OEPart: Part public class ProductLi

在C#中,我使用实体框架和MVC,并拥有:

public class Part

public class FinishedGoodsPart: Part
   public int? ProductLineId { get; set; }

public class CompetitorPart : Part
   public int? ProductLineId { get; set; }

public class OEPart: Part

public class ProductLine
   public virtual ICollection<Part> Parts { get; set; }
公共类部分
公共类FinishedGoodPart:部分
公共整数?ProductLineId{get;set;}
公共级竞赛部分:第二部分
公共整数?ProductLineId{get;set;}
公开课部分:部分
公共类产品线
公共虚拟ICollection部分{get;set;}
请注意,FinishedGoodPart和CompetitorPart有一条生产线,但OEPart没有

这将在FinishedGoodsPart和CompetitorPart表中放置一个名为ProductLine_Id的列,正如我所期望的那样,但也会在表部分中放置ProductLine_Id列(我不希望这样)

如何防止E.F.添加列Part.ProductLine\u Id?有更好的设计吗

目标是ProductLine模型对象的实例将具有属于该产品线的所有零件的列表(无论是竞争对手零件还是成品零件)。但OEPart不允许设置ProductLine


FinishedGoodPart对象将有很多属性,而Competitor或part将只有很少的属性,因此我不想将所有零件记录存储在一个数据库表中。

ProductLine。Parts
定义了
ProductLine
part
之间的关系。EF只能在
部分为它创建一个外键。有更好的解决方案吗?理想情况下,我希望ProductLine对象上有一个列表,列出与其关联的所有部分(无论子类如何)。
ProductLine.parts
定义了
ProductLine
Part
之间的关系。EF只能在
部分为它创建一个外键。有更好的解决方案吗?理想情况下,我希望ProductLine对象上有一个列表,列出与其关联的所有部分(无论子类如何)。