0
votes

I am trying to create a WPF project with MVVM and ADO.Net Entity Framework. I do have a few questions though.

  1. Do i create the Entity Framework Model in the Model Folder of the MVVM Design?
  2. Or do i have to create a new project for each item of the MVVM Model(i.e Views Project as a WPF Project,Model Project as a class libraray, ViewModel project as a class library)?
2

2 Answers

0
votes

It doesn't really matter where you put stuff, but yes I usually put all my EF or Linq-Sql stuff in a Model folder as they will usually house all of my model classes anyway and it keeps it all together. It is a bit of a grey area though, because it's also doing DataLayer stuff, so just bear that in mind too.

Regarding your 2nd point, no. The Model, View Models and Views should all be in the same project.

Take a look at this for some guidance on MVVM.

0
votes

Do i create the Entity Framework Model in the Model Folder of the MVVM Design?

I usually create a separate project for the model which is storage ignorant (using POCOs) and also usage ignorant.

Or do i have to create a new project for each item of the MVVM Model(i.e Views Project as a WPF Project,Model Project as a class libraray, ViewModel project as a class library)?

If you are planning on having more than one type of view-model per model (e.g. one for WPF, one for a service, one for another service), then separate your view-models into their own assembly.

If your views only represent one model layer, then you can start out your views and view-models in the same assembly, then separate them if you get to a situation that you have multiple models under the same view (each with its own view-model).


You should also consider if you want the ADO.NET's model to be your main model (upon which you base your view-models), or if you want to treat it as a sort of view-model for storing (where the storage service is a sort of view).