views:

341

answers:

6

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.

A: 

Model folder is more a convention from MVC- Model View Controller. You can use any folder to store your model, or even in another assembly it depends upon your project structure requirement or wish.

diadiora
+4  A: 

Very different to App_Code as the App_Code folder is treated as content and compiled at runtime. App_Code is special in this way. By the way you should stay away from App_Code if you want to get compiler errors from your code rather than runtime errors.

Jonathan Parker
A: 

We typically store our dbmls in that folder. You could, as @diadiora explained add an assembly or your data layer code.

It's a way to aggregate functional aspects of the MVC pattern. Much like when you spin up a Ruby on Rails application, I think Microsoft is trying to enforce principles of opinionated programming and structure.

Nick
A: 

In a project where we use llblgen models, I have a folder named llblgen for generated models and a folder custom for stuff we build ourselves.

You can do with the folder what you want, just try to organise things a bit logical so someone unfamiliar with your project could make sense of it.

Morph
+2  A: 

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.

Dragan Panjkov
+2  A: 

Models is the M in MVC. Though no functionality is provided in the default project template it's meant to be used by a data access technology. Whether it be web services, ado.net, linq to sql, nhibernate, etc.

Of course you don't have to put it there you could put each part of the project in it's own project, it's up to you. It's simply there to help facilitate the MVC pattern and has no actual function.

Chad Moran