Asp – Best practices regarding locations for ASP.NET MVC models

asp.net-mvcmodel

Are there any best practices that cover the places that ASP.NET MVC models should be defined?

A new ASP.NET MVC project has a nice neat Models folder for them to go in, but in a production environment they can come from other places:

  • Third party class libraries
  • WCF services

Is it acceptable for a strongly-typed view to use a class defined in such a location?

Best Answer

In just about every project I have worked on the models of ASP.NET MVC are more View Models than models in the traditional sense of the word. I have yet to have a project where I can use the same Model that I use in my data access for my View Model. There is just too much other information that needs to be displayed on most pages. So for that reason I will either store my models in the models folder or store them in a separate library with all of my other MVC specific classes.