我有一个抽象的基类,它具有name属性和[NotMapped]属性
public abstract class EntityBase
{
[Key]
public string id { get; set; }
[NotMapped]
abstract public string name { get; set; }
}
还有一个继承自EntityBase的子类
public class Person: EntityBase
{
public override string name { get; set; }
[Emailaddress]
public string email { get; set; }
[Phone]
public string phone { get; set; }
}
我执行 add-migration Migration20191106 和 Update-Database 生成迁移文件并映射到数据库,但是它没有创建 name 字段,尝试更改EntityBase类:
[NotMapped]
public virtual string name { get; set; }
并更改Person类:
[Required]
public override string name { get; set; }
但是得到相同的结果。
我想知道带有[NotMapped]属性的名称字段如何映射到数据库,非常感谢!