Benjamin
Benjamin

Reputation: 3234

How can I detect a [NotMapped] annotation from PropertyInfo or MetaData?

If I have the PropertyInfo for a property or the MVC MetaData for that property, how can I detect whether it has the [NotMapped] annotation from EF CodeFirst? Thanks.

Upvotes: 6

Views: 1202

Answers (1)

Dirk von Grünigen
Dirk von Grünigen

Reputation: 332

You can achive it like that:

youPropertyInfo.GetCustomAttributes(typeof(NotMappedAttribute), true).Count() > 1

Upvotes: 8

Related Questions