Asp.net MVC 自己写的验证被覆盖问题
问一下各位高手怎么处理MVC中验证被覆盖问题。
情景如下:
我用Entity framework对数据库生成Model,然后为了验证消息在属性上添加验证消息.形式如下:
/// <summary>
/// There are no comments for property CategoryName in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
[Required("Category Name can't be null")]
public string CategoryName
{
get
{
...
}
set
{
...
}
}
问题是如果我现在数据库更改了,在Entity framework设计器中从数据库更新数据模型。则以前写的所有的这种验证都会被覆盖。请问各位有什么好的处理方法吗?谢谢