标签: c# entity-framework ef-code-first data-annotations
我正在使用实体框架代码优先,所以我自由地使用数据注释。我使用来自[Key]的{{1}}注释,并注意到它没有客户端验证,因为它继承自sealed class KeyAttribute类,而不是Attribute类。< / p>
[Key]
sealed class KeyAttribute
Attribute
因为类是ValidationAttribute,所以我无法继承它。是否有其他方法可以通过数据注释添加验证,而无需简单地创建另一个模仿sealed的属性?
ValidationAttribute
sealed
(我试图避免像[Key])