Entity Framework中System.Data.Entity.Validation.DbEntityValidationException
时间:2011-05-27 来源:gongzhw
[Required(ErrorMessage = "*电话"), StringLength(30, MinimumLength = 6, ErrorMessage = "请输入电话6到30位数字")] public string Tel { get; set; } [Required(ErrorMessage = "*地址"), StringLength(150, MinimumLength = 10, ErrorMessage = "请输入家庭地址10到80位")]
如果model中使用了MinimumLength 来限制字段最小长度,在添加到时候没有按照此规则添加数据 就会得到下面的错误:
System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details
相关阅读 更多 +