0

I have the following class generated by EntityFramework,

public partial class Person
{
    public string FirstName { get; set; }
    public string Lastname { get; set; }
}

Now I would like to add custom Attributes before using it or modifying the above class dynamically using reflection. Something like below,

public partial class Person
{
    [SomeCustomAttribute]
    public string FirstName { get; set; }
    [SomeCustomAttribute]
    public string Lastname { get; set; }
}

Is it possible to add custom attributes using reflection?

Devolus
  • 21,661
  • 13
  • 66
  • 113
  • This is a better link for duplicate as the previous one doesn't really cover what peplamb wants. http://stackoverflow.com/questions/5889349/displayname-on-model-that-use-entity-framework – Lee O. Jan 17 '14 at 18:45
  • 1
    IE...the answer is really to either use a custom T4 template or make your EF classes just plain data access classes and put the attributes on a wrapper class for the UI. – Lee O. Jan 17 '14 at 18:47

0 Answers0