how to use the ADO.NET Entity Framework and Validation together with the catel

Sep 30, 2011 at 7:12 PM

Hi 

I am using Ado.NET Entity Framework in my project
How can I handle a Validation Error in my ViewModel ?

Coordinator
Oct 1, 2011 at 9:20 AM

Hi,

Entity Framework uses the Validation attributes to add validation. Catel supports the following cases:

1) The model implements IDataErrorInfo

2) The model implements INotifyDataErrorInfo

3) The mapped property or the property in the view model has validation attributes (yes, you can use the validation attributes on the view model as well if you like, be don't recommend that)

 

In other words, are you mapping the properties of the model correctly in your view model? Or what is your exact question?

Best regards,

Geert

Oct 1, 2011 at 8:52 PM

i don't have any  Knowledge about Validation In MVVM :)

would it be ok you help me out about implement  validation in term of MVVM

Because i know about validation in general

 Can you explain more about the implements INotifyDataErrorInfo Or introduce an article or simple example 

I used the following Items in Catel Project 
DataContext.edmx 

-----------------

Customer Model

Order Model

-----------------

ViewModels

----------------

CustomerViewModel  -- Actions --> CRUD

OrderViewModel       -- Actions --> CRUD

----------------


I really appreciate your help

Coordinator
Oct 2, 2011 at 8:07 AM
  1. The first step is to add validation to entity framework. Here is an excellent article about validation in Entity Framework
  2. Catel will now automatically take over all validation as long as you define the ModelAttribute with it
  3. Last but not least, you can add, remove or customize validation in the ViewModelBase.ValidateFields method. See this documentation for more information.
Oct 14, 2011 at 7:14 PM

hi geert

I'm new to WPF &  MVVM 

Do you can, please, put a complete example using a Entity Framework 

Coordinator
Oct 15, 2011 at 5:36 AM

Hi Sarapersi,

Creating a full example with EF is a bit out of scope, and there are other priorities first. However, it's very simple, because you can create a new Silverlight application using the Catel project templates. Then, add a DAL (Data Access Layer), and finally add a domain service class to your web project.