I want to build a basic wpf/mvvm application which gets the data from a server with WCF and allows the client to display/manipulate (with CRUD operations) this data.
So far, I thought about something like that for the architecture :
- a "global" model layer, which implements validation, research criterias, and INotifyPropertyChanged and services contracts
- some services layers, by mainly one for entity framework 4, implementing the contracts of the model layer and allowing me to access and manipulate data.
- Note that I want to have an offline datasource as well, say XML or something else, and thus another service (I plan on using some DI/IoC)
- the WCF layer
- Extra layer for data storing client side ?
- the ViewModel
I'm clear on the Views/ViewModel part, but I have troubles figuring out the relations between the model, WCF and the viewmodel.
My questions are :
- How should I handle the model generated by EF ? Get rid of it and go for a code first approach, manually doing the mapping with the database ?
- For the WCF data transport, should I have relational properties in my model, i.e a Product has a Customer instead of a CustomerId ?
- Should I have an additional layer between the WCF and the ViewModel, for storing and manipulating data or is it a best practice to directly plug the ViewModel into the WCF ?
Any other tips for this kind of architecture are welcome...