My question is very simple. I want to know where to put my ViewModels
in an MVC application.
Currently the project I'm working on only has ViewModels
and they are stored in the Models
folder. In that folder we directly create ViewModel classes.
But normally I would also have Model
classes, to get data from a database or something. Then from a Controller
I'd 'talk' to a Model method and store the result in a ViewModel
property.
But where do I put the Model
classes and ViewModel
classes when I use both of them? What is a good practice in the sense of structuring my files/folders for these two?
ViewModel
folder. There are no constraints which state that theModel
folder should be present. – DonatusViewModel
in a ViewModels folder and aModel
in a Models folder? – GaultheriaViewModel
as a sub folderModel
, if you're using both to display data in the views. If not, separate folders would make more sense to me. – Donatus