Validation of Entity Framework

.net c# entity-framework validation

Question

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.

1
16
9/4/2012 4:18:43 AM

Accepted Answer

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.

11
10/19/2008 3:30:26 AM

Popular Answer

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...



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow