protected override CachedDataAnnotationsModelMetadata CreateMetadataPrototype(IEnumerable <Attribute> attributes, Type containerType, Type modelType, string propertyName) { var attributesList = attributes.ToArray(); Func <IEnumerable <Attribute>, CachedDataAnnotationsModelMetadata> metadataFactory = attr => base.CreateMetadataPrototype(attributes, containerType, modelType, propertyName); var conventionType = containerType ?? modelType; var defaultResourceType = DefaultResourceType; var conventionAttribute = conventionType.GetAttributeOnTypeOrAssembly <MetadataConventionsAttribute>(); if (conventionAttribute != null && conventionAttribute.ResourceType != null) { defaultResourceType = conventionAttribute.ResourceType; } else if (RequireConventionAttribute) { return(metadataFactory(attributesList)); } ApplyConventionsToValidationAttributes(attributesList, containerType, propertyName, defaultResourceType); var foundDisplayAttribute = attributesList.FirstOrDefault(a => a is DisplayAttribute) as DisplayAttribute; if (foundDisplayAttribute.CanSupplyDisplayName()) { return(metadataFactory(attributesList)); } // Our displayAttribute is lacking. Time to get busy. var displayAttribute = foundDisplayAttribute.Copy() ?? new DisplayAttribute(); var rewrittenAttributes = attributesList.Replace(foundDisplayAttribute, displayAttribute); // ensure resource type. displayAttribute.ResourceType = displayAttribute.ResourceType ?? defaultResourceType; if (displayAttribute.ResourceType != null) { // ensure resource name string displayAttributeName = GetDisplayAttributeName(containerType, propertyName, displayAttribute); if (displayAttributeName != null) { displayAttribute.Name = displayAttributeName; } if (!displayAttribute.ResourceType.PropertyExists(displayAttribute.Name)) { displayAttribute.ResourceType = null; } } CachedDataAnnotationsModelMetadata metadata = metadataFactory(rewrittenAttributes); if (metadata.GetDisplayName() == null || metadata.GetDisplayName() == metadata.PropertyName) { //metadata.Properties[0]..se.DisplayName = metadata.PropertyName.SplitUpperCaseToString(); } return(metadata); }