I use the MetaDataType attribute in the class of my domain model. It must move the attribute information from the reference class to the class that was set by the MetadataType attribute. But this is not as advertised. What causes the problem here?
[MetadataType(typeof(ComponentModelMetaData))] public partial class Component { public int Id { get; set; } public string Name { get; set; } public ICollection<Repo> Repos { get; set; } public string Description { get; set; } } public class ComponentModelMetaData { [Required(ErrorMessage = "Name is required.")] [StringLength(30, MinimumLength = 3, ErrorMessage = "Name length should be more than 3 symbols.")] public string Name { get; set; } public ICollection<Repo> Repos { get; set; } [Required(ErrorMessage = "Description is required.")] public string Description { get; set; } }
c # asp.net-core data-annotations
Meta Jan 03 '15 at 13:15 2016-01-03 13:15
source share