Я сгенерировал свой DbContext с помощью EF с установленным DataAnnotations и хотел бы переопределить свойство Required ErrorMessage с помощью ModelMetadataType
например,
Сгенерированный класс
public partial class ControlType
{
public ControlType()
{
Rule = new HashSet<Rule>();
}
[Key]
public int ControlTypeId { get; set; }
[Required]
[StringLength(200)]
public string Name { get; set; }
[InverseProperty("ControlType")]
public virtual ICollection<Rule> Rule { get; set; }
}
Мое расширение class
[ModelMetadataType(typeof(ControlTypeMeta))]
public partial class ControlType
{
}
public class ControlTypeMeta
{
[Display(Name = "Id")]
public int ControlTypeId { get; set; }
[Display(Name = "Control type")]
[Required(ErrorMessage = "'{0}' is required")]
public string Name { get; set; }
}
С учетом вышесказанного я ожидаю, что Required ErrorMessage будет выведено как "'Control type' required", но вместо этого я получу значение по умолчанию "Поле Control type required"
![screenshot](https://i.stack.imgur.com/0cCIQ.png)
Кто-нибудь знает, как я могу переопределить сообщение (без создания моделей представления)