문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top