Your viewmodels should be in the "Models" folder of your MVC project. Essentially with EF code first your c# classes may directly become your presentation model as well, if there's a one to one mapping.
But if you need to create a specific model which is composed of other data model, then "Models" should be a place to go.
Your EF model will definitely be in a separate DB model assembly so that those changes could be kept separately.
The other thing is you can also put all your view models in a separate assembly for granular abstractions of presentation model if required.
I blog at http://rajeshpillai.net and have a community startup http://ownabook.org/
(Don't forget to click "Mark as Answer" on the post(s) that helped you.)
Marked as answer by enendaveyboy on Mar 18, 2012 04:04 AM
Thanks, but if I send a view model to the view, what I am doing at the moment is putting them in a view model and sending them to the view is this incorrect?
EnenDaveyBoy
Participant
1465 Points
1147 Posts
Where do I put viewModels question
Mar 17, 2012 02:01 AM|LINK
Hi
I have a solution which has a core, data, and service project, plus a UI MVC project, I have all by database code first models in the data.
Am i right to have two folders in core,one for a copy of the entity models in data, but with extra validation and similar methods
one for viewmodels, which will contain models which would have multiple core models?
if not where do I put them?
thinkrajesh
Participant
1356 Points
232 Posts
Re: Where do I put viewModels question
Mar 17, 2012 04:01 AM|LINK
Your viewmodels should be in the "Models" folder of your MVC project. Essentially with EF code first your c# classes may directly become your presentation model as well, if there's a one to one mapping.
But if you need to create a specific model which is composed of other data model, then "Models" should be a place to go.
Your EF model will definitely be in a separate DB model assembly so that those changes could be kept separately.
The other thing is you can also put all your view models in a separate assembly for granular abstractions of presentation model if required.
(Don't forget to click "Mark as Answer" on the post(s) that helped you.)
EnenDaveyBoy
Participant
1465 Points
1147 Posts
Re: Where do I put viewModels question
Mar 18, 2012 01:29 AM|LINK
Thanks, but if I send a view model to the view, what I am doing at the moment is putting them in a view model and sending them to the view is this incorrect?
EnenDaveyBoy
Participant
1465 Points
1147 Posts
Re: Where do I put viewModels question
Mar 18, 2012 04:04 AM|LINK
its ok sorted