Validation failed for one or more entities. See 'EntityValidationErrors' property for more details

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details

在ASP.NET MVC项目中,当在某一个强类型视图页点击"添加"按钮时,报Validation failed for one or more entities. See 'EntityValidationErrors' property for more details错。

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details

 

原因分析:主要是由于View Model中字段的类型、长度或者是否为null与数据库表字段不一致引起的。

 

解决办法:修改View Model中或数据表字段,使他们的类型、长度、是否为null保持一致。