In Core, creating an Areas section creates an empty "Data" folder in it by default.
Areas
Dining
Controllers
Ingredient
Data <-
Models
Ingredient
Views
Ingredient
Create
Delete
Details
Edit
Index
Like versions prior to core, the
beginners core tutorial directs the user to create a "Data" folder into which to place the project context (it would not be created by default like it is in the Areas section)
Areas
Controllers
Data <-HomeContext
Models
Views
In previous versions to core the Data folder containing the project context would contain any code necessary to create property sets in the Areas section.
Questions:
Is this true of core...that I don't need to have a separate context - or any code - in the Areas.Data folder to create property sets under the Areas section?
And if so, why is there a Data folder created under Areas by default?
File structure below
Areas
Dining
Controllers
Ingredient
Data
Models
Ingredient
Views
Ingredient
Create
Delete
Details
Edit
Index
Controllers
Data
HomeContext
Models
Views
Areas provide a way to partition anASP.NET Core Web app into smaller functional groups, each with its own set of Razor Pages, controllers, views, and models. An area is effectively a structure inside an app. In an ASP.NET
Core web project, logical components like Pages, Model, Controller, and View are kept in different folders.
<end>
The total solution can be made up of smaller solutions within it, like Inventory, Shipping, Purchase Order, etc. and etc. The Areas allowing each solution within the total solution to be independent and segregated from each other. So there could be a database
solely for Purchase Order, one for Shipping, etc. etc. So why would there not be a Data folder hodinmg a dbcontext for each functionality/solution within the total solution?
If your solution doesn't warrant a Data folder, then you can delete it.
To me, Areas and the folders within it are another means of implementing SoC.
Context is for the entire project, and Area is just a region that provides a way to divide ASP.NET Core web applications into smaller functional groups, which is actually the internal structure of the application.So it is not necessary to define Context
for each Area separately.
Besides, the document doesn't mention that there is a Data folder in Area.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
361 Points
823 Posts
Areas.Data v Project.Data folders Re: Project Context
Mar 30, 2020 08:26 PM|3v3rhart|LINK
In Core, creating an Areas section creates an empty "Data" folder in it by default.
Areas Dining Controllers Ingredient Data <- Models Ingredient Views Ingredient Create Delete Details Edit Index
Like versions prior to core, the beginners core tutorial directs the user to create a "Data" folder into which to place the project context (it would not be created by default like it is in the Areas section)
In previous versions to core the Data folder containing the project context would contain any code necessary to create property sets in the Areas section.
Questions:
Is this true of core...that I don't need to have a separate context - or any code - in the Areas.Data folder to create property sets under the Areas section?
And if so, why is there a Data folder created under Areas by default?
File structure below
Contributor
4963 Points
4209 Posts
Re: Areas.Data v Project.Data folders Project Context
Mar 30, 2020 11:49 PM|DA924|LINK
https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/areas?view=aspnetcore-3.1
<copied>
Areas provide a way to partition an ASP.NET Core Web app into smaller functional groups, each with its own set of Razor Pages, controllers, views, and models. An area is effectively a structure inside an app. In an ASP.NET Core web project, logical components like Pages, Model, Controller, and View are kept in different folders.
<end>
The total solution can be made up of smaller solutions within it, like Inventory, Shipping, Purchase Order, etc. and etc. The Areas allowing each solution within the total solution to be independent and segregated from each other. So there could be a database solely for Purchase Order, one for Shipping, etc. etc. So why would there not be a Data folder hodinmg a dbcontext for each functionality/solution within the total solution?
If your solution doesn't warrant a Data folder, then you can delete it.
To me, Areas and the folders within it are another means of implementing SoC.
https://en.wikipedia.org/wiki/Separation_of_concerns
Participant
1320 Points
491 Posts
Re: Areas.Data v Project.Data folders Project Context
Mar 31, 2020 02:18 AM|jiadongm|LINK
Hi 3v3rhart,
Context is for the entire project, and Area is just a region that provides a way to divide ASP.NET Core web applications into smaller functional groups, which is actually the internal structure of the application.So it is not necessary to define Context for each Area separately.
Besides, the document doesn't mention that there is a Data folder in Area.
https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/areas?view=aspnetcore-3.1
Best Regards,
Jiadong Meng