Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC ,What is the Models Folder for?

Tags:

asp.net-mvc

Another repository of App_Code? Inside the NerdDinner sample, it contains some share interface, function , class with property etc. Not much different with App_Code.

like image 825
Cheung Avatar asked May 13 '09 06:05

Cheung


1 Answers

Basic idea for existence of Models folder is to keep your objects which you manipulate with. It's a convention in order to maintain MVC paradigm (Model-View-Controller). In basic ASP.NET MVC application you store L2S DataContext class or EF context class into Models folder.

The need for additional classes (files) in the Models folder can be explained by the idea of partial classes: all classes inside DataContext file are partial, and as such, can be extended with additional properties and methods.

If you divide your MVC application into multiple projects, you don't need to use Models folder at all, because your DAL will be in DLL you reference from your MVC web application.

like image 145
Dragan Panjkov Avatar answered Nov 15 '22 08:11

Dragan Panjkov