There is no "default" for the project structure, except what Microsoft itself mounts for you, which is the most recommended.
In this base template, you already have everything in its proper place. If you create a template with Identity (Individual User Accounts) will see that the Context
is in the same folder as Models
. If Microsoft did so, there is a reason.
When looking at the tutorials on the internet, you will always see numerous types of structures, the most common is to separate into three projects:
They say this is a three-layer separation, which is not true. The folder structure does not indicate whether the system has three layers or not: it is just a way to structure the project, which is not always good.
Below you can see the structure model generated by Visual Studio, in the project
MVC Music Store, where you can follow the tutorial and see how Microsoft organized this project.
On the other hand, it can vary from project to project, creating a project for your Models
, for reuse, a project for other platforms... there are other models, as in everything, but not always that there is something, that will be the best option.
There are some models that you need to know, which are:
- Every Controller must end with the word Controller, e.g.: ProfileController
All Attribute
should end with the word Attribute, ex: CpfAttribute
Partialview should start with _ before the name (not required, but the default), e.g.: _Menu
.
- Every Context must end with the word Context, (not required, but the default) e.g..
- Shared folder can be accessed by any
View
, then put a PartialView
that will be accessed by more than one controller in the Shared folder, thus avoiding the repetition of the same.
In this template you can still add folders to your Viewmodels, Helpers, Extensions, etc. Just try not to complicate what there is no need to be complicated.
The best skeleton is the one that VS itself mounts for you. There is no standard for the name of solutions/projects. Often there are too many complications and no utilities.
– Randrade
Thank you for the information.
– Mauricio Ferraz