0
votes

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?

2
And what is the question? You have already found solution. - Ladislav Mrnka
I am not able to make it working using Partial classes. Can you suggest something ? - Anil
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
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
How are you using dataannotation in wpf. Post some code. - Ladislav Mrnka

2 Answers

1
votes

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.

0
votes

There is no need to registered the Data Annotations. Just followed the steps mentioned in the article & its working now.