seddler
seddler

Reputation: 97

Entity Framework: add property that don't map to database

Is it possible to add a property to an entity where the property is not supposed to map to the database?

Upvotes: 5

Views: 7824

Answers (2)

Edd
Edd

Reputation: 701

You need to mark the property in the custom partial class to "[NotMapped]". Hope this helps.

Upvotes: 15

Craig Stuntz
Craig Stuntz

Reputation: 126547

Possible? Sure; add it to a custom partial class matching your entity type. Useful? Less so; you (mostly) can't use them in LINQ to Entities queries, and you shouldn't re-purpose your entities as view models.

Upvotes: -2

Related Questions