MagiKruiser
MagiKruiser

Reputation: 471

EF Generated Classes & MVVM Project

I started a project trying to respect a MVVM pattern and using Entities Framework, however I'm a bit confused regarding the different layers organisation.

Here's my current concern: EF generates POCO classes accordingly to my database structure. If I understood, those should therefore be my Models. The interactions with the Database are excluded from the basic MVVM pattern (they belong to an extra Layer - generally called Data from what I've seen -)

However those POCO classes do not implement INotifyPropertyChanged, which is from the few I've seen / understood of MVVM at the moment, a pretty much keypoint as it's what allows Binding to work.

I've come accross few links regarding this matter, but mostly different answers I read are just getting my head more and more confused.

Coming down to a more concise question: In order to complete POCO classes generated and implement INotifyPropertyChanged, what would be the ideal solution ?

Thanks.

Upvotes: 2

Views: 243

Answers (1)

NDJ
NDJ

Reputation: 5194

personally I'd create ViewModel objects which expose the elements of your POCO objects the UI is interested in - it seems like a fair amount of duplication but it separates your UI from the underlying business/data objects.

Upvotes: 1

Related Questions