There was the same problem, and I made a workaround for her. I know this is not perfect.
For each dataannotation attribute, create a new class
public class RequiredAttribute : System.ComponentModel.DataAnnotations.RequiredAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { validationContext.DisplayName = ModelMetadataProviders .Current .GetMetadataForProperty(null, validationContext.ObjectType, validationContext.DisplayName) .DisplayName; return base.IsValid(value, validationContext); } } public class StringLengthAttribute : System.ComponentModel.DataAnnotations.StringLengthAttribute { public StringLengthAttribute(int maximumLength) : base(maximumLength) { } protected override ValidationResult IsValid(object value, ValidationContext validationContext) { validationContext.DisplayName = ModelMetadataProviders .Current .GetMetadataForProperty(null, validationContext.ObjectType, validationContext.DisplayName) .DisplayName; return base.IsValid(value, validationContext); } }
etc....
Sebastien
source share