1

Closed

Unable to implement ValidatableViewModelBase in EF extended partial class

description

I wanted to try and add some validation rules directly in the EF model but when I add a partial class and implement ValidatableViewModelBase I get errors in the EF automatically created partial class for each properties' ReportPropertyChanging and ReportPropertyChanged methods. I'm no expert in c# or EF so this might be an obvious observation with no workaround. But if there were I'd very much appreciate some direction.
Thanks anyway for a really cool framework.
Closed May 1, 2012 at 7:24 PM by pglazkov
Well, having ValidatableViewModelBase as a base class of an EF model is not the intended use of this class. As the name suggests, it is a base class for a View Model, not model.

Anyway, the reason you were getting errors is that the other part of the EF partial class already implements the INotifyPropertyChanged interface, while ValidatableViewModelBase inherits ViewModelBase that has its own implementation of this interface.

I would recommend you to create a view model class that would wrap your EF model and bind it to UI, rather than binding the EF model directly.

If you still want to use EF model directly, you can just create your own base class for such scenarios (lets say ValidatableModelBase) and implement IDataErrorInfo interface in it using DataErrorInfoAdapter class just like it is done in ValidatableViewModelBase.

comments