Question

Is it possible to apply custom attributes to code first entity framework objects without entity framework discarding them at runtime?

I want to decorate my class objects with not only data annotations relating to Entity Framework specific conditions, but to also include custom attributes to the classes that refer to other areas of my project, for e.g, Lucene.Net, where i may wish to declare Field specific attributes regarding a Lucene field or index.

If anyone has had experience of doing something similar to this I'd appreciate some advice or useful links.

Was it helpful?

Solution

If you are doing code first you should be able to add whatever attributes you want. Since you're not generating the entities through a designer they won't be deleted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top