问题描述
在哪里使用CTP 5 CodeFirst TPH并且在以下情况中似乎存在持久性问题:
Where are using the CTP 5 CodeFirst TPH and there seems to be a persistence issue in the following scenario:
public class Product
{
public int ID { get; set; }
public virtual string Name { get; set; }
public string SomeOtherProperty { get; set; }
}
public class SpecialProduct : Product
{
[System.ComponentModel.DataAnnotations.NotMapped]
public override string Name { get; set; }
[System.ComponentModel.DataAnnotations.NotMapped]
public string ProperlyIgnoredProperty { get; set; }
}
推荐答案
这不是受支持的方案。这实际上是EF(不仅仅是Code First)的一个基本限制,派生类型必须具有其基类型的所有属性。
This isn't a supported scenario. This is actually a fundamental restriction of EF (not just Code First), that a derived type must have all the properties of its base type.
如果你想看到对此添加的支持EF,我们有一个用户语音网站,您可以在其中添加和投票功能; https://data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-suggestions
If you wanted to see support for this added to EF, we have a User Voice site where you can add and vote on features; https://data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-suggestions
~Rowan
这篇关于CTP5错误? - CodeFirst TPH - 在子类中标记为NotMapped的重写列的持久值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!