I am working on WPF application which uses Entity Framework alongwith POCO classes. I would like to use data annotations with POCO classes for Client side validations in UI (WPF). Since, I can't modify the POCO classes (it will be regenerated after updating the entity model), therefore, I have implemented the data annotations using partial class as per approach mentioned in the article: http://www.asp.net/mvc/tutorials/validation-with-the-data-annotation-validators-cs under section "Using Data Annotation Validators with the Entity Framework". Somehow this approach is not working in my case. Can anybody suggest something as to how can I use data annotation with Entity Framework?
-
And what is the question? You have already found solution.Ladislav Mrnka– Ladislav Mrnka2011-03-15 10:49:40 +00:00Commented Mar 15, 2011 at 10:49
-
I am not able to make it working using Partial classes. Can you suggest something ?Anil C– Anil C2011-03-15 11:04:10 +00:00Commented Mar 15, 2011 at 11:04
-
If I specify the data annotations in POCO classes, it started working fine but not as per the approach mentioned in the above article. Any ideas ?Anil C– Anil C2011-03-15 11:18:09 +00:00Commented Mar 15, 2011 at 11:18
-
That approach is the solution. If it doesn't work for you, post the related code so that we can try to figure out the problem.Yakimych– Yakimych2011-03-15 12:30:22 +00:00Commented Mar 15, 2011 at 12:30
-
How are you using dataannotation in wpf. Post some code.Ladislav Mrnka– Ladislav Mrnka2011-03-15 13:40:58 +00:00Commented Mar 15, 2011 at 13:40
|
Show 1 more comment
2 Answers
You might have a look at the BookLibrary sample application of the WPF Application Framework (WAF). It shows how to use data annotations with the Entity Framework. And it shows how to consume it in WPF so that the validation errors are shown.