EF Code First 数据注释和继承

EF Code First Data Annotations and Inheritance

我正在使用代码生成来创建实体集,我希望能够像这样设置它们:

[Table("Person")]
public class Person_Generated {
   [Key]
   [Column("PersonId")]
   public virtual int? PersonId { get; set; }
}

public class Person : Person_Generated { }

这将允许我稍后在 Person class 中 add/override 自定义属性。问题是,当我尝试使用 Person 进行查询时,出现此错误。

An unhandled exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll

Additional information: The type 'Person' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive or generic, and does not inherit from EntityObject.

我只是继续使用部分 类,因为它似乎继承 类 有问题。