I've been reading up on the entity framework as I get ready to start a new project. What is the best method for verifying the entities, I wonder? The majority of the validation in other projects I've worked on has utilized attributes; however, the entity architecture explicitly prohibits this. Is handling the partial methods in the property setters the only way to do this? All suggestions are much appreciated.
Although I haven't really utilized Entity framework before, a short search reveals that there are a lot of alternatives.
1) Perform validation at a lower application layer.
It's always a possibility, but I though I'd make it clear.
2) Perform validation by hooking into the Entity's OnChanged events.
If you have many distinct attributes that may change for each object, your system would probably be fragile and sluggish after a while.
3) Use imperfect techniques to verify property changes
The this post and this walkthrough both mention that there are several incomplete techniques for validation. This seems to be the best solution since it is not too invasive and you may execute the desired validation only in certain circumstances.
Hope that was helpful. Good fortune.
Entity-Framework will include out-of-the-box validation functionality in.NET 4.
Look at: zzzz-9 zzzz
Therefore, don't put too much effort into developing overly intricate validation logic...