The encodings of models, views, and ViewModels are really just layers of your application. Their actual location does not matter if the interaction between them does not violate the MVVM pattern.
However, I try to follow the pattern set by ASP.NET MVC and the T4Scaffolding NuGet package. After installing this package, you can run the following command.
Scaffold Repository -ModelType Person
This will create two new classes for you based on the Person model class.
- Models \ MyApplicationContext.cs
- Models \ PersonRepository.cs
The first is just the standard DbContext class, as you would expect. It is not intended that your Views or ViewModles interact directly with this class. The repository class provides an abstraction by context; this is the one you have to go between layers. The repository is also much easier to trick than DbContaxt, and it can be easily implemented using a completely different technology, such as WCF data services.
Hope this answer at least gives you a good place to start.
source share