我正在使用Entity Framework Model-First,我想为edmx中的每个实体实现BaseEntity
。我无法在任何地方找到可行的解决方案。任何人都可以帮我这个吗?
这就是BaseEntity
的样子:
public abstract class BaseEntity
{
[Required]
public bool IsDeleted { get; set; }
[Required]
public DateTime Created { get; set; }
[Required]
public string CreatedBy { get; set; }
[Required]
public DateTime LastModified { get; set; }
[Required]
public string LastModifiedBy { get; set; }
}
我希望我的datamodel中的每个实体都具有这些属性以用于管理目的。 BaseEntity
是在edmx之外定义的,因为我无法在OnModelCreating
中忽略它,因为我使用的是Model-First。
我知道我可以在设计师手工为每个Inheritance
指定Entity
,但这将是很多工作,我的设计将不会保持非常灵活