2

Given the class:

public class Item
{
    [Key]
    public int ID { get; set; }

    [Display]
    public string Name { get; set; }

    public string Observation { get; set; }
    public DateTime? Done { get; set; }
}

I know i can define my [Key] Attribute and other mapping settings by create a mapping class in another project and inheriting from EntityTypeConfiguration.

but how can i replace the [display] attribute so i don't have to add a reference to System.ComponentModel.DataAnnotations to my common dll?

tell me if i'm not clear enough

Bruno Avelar
  • 670
  • 4
  • 16

1 Answers1

1

You can create your own attribute, then write a class that inherits AssociatedMetadataProvider and reads data from your attribute into a ModelMetadata instance.

Your class would be similar or identical to the built-in version.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964