0
我需要使用Entity Framework 4.3來映射下面的類層次結構。如果在Entity Framework 4.3中的不同實體下出現同一個子實體,它將如何映射到不同的表中?
public abstract class Rule
{
public long Id {get;set;}
public abstract ICollection<Parameter> Parameters {get;set;}
}
public class Entity1
{
public long Id {get;set;}
public ICollection<Rule> Rules {get;set;}
// Map Rule to table Entity1Rules and
// Parameters to table Entity1RuleParameters
}
public class Entity2
{
public long Id {get;set;}
public ICollection<Rule> Rules {get;set;}
// Map Rule to table Entity2Rules and
// Parameters to table Entity2RuleParameters
}
感謝
這被稱爲「多態關係」,這是一種可以被[各種數據模型]所適應的模式(http://stackoverflow.com/questions/8895806/how-to-implement-polymorphic-associations-in-an-現有的數據庫)。 – 2012-03-13 20:19:36