I am developing an asp.net mvc solution, which contains the three layers:
Data Access Layer
Business Layer
Entity Layer
Each layer is a project.
I have developed the controllers and views, but no Models. Instead of using Model, I am using the Entity layer as Model.
My question is: Is this still an MVC project?
I attach an image of my solution to better explain my question.
-
Despite the name, the Models directory is meant to be used for ViewModels. Often, a View requires data that is specific to the View itself (think "element is minimized"). These kinds of properties tend to clutter/obfuscate the purpose of objects so they are best segregated into dedicated ViewModels. While you can certainly opt out of using ViewModels, for anything other than a trivial CRUD application you are going to end up polluting your Entities with View state. FWIW, The UI layer is always the most tedious layer to develop.user3347715– user33477152018年08月15日 18:39:39 +00:00Commented Aug 15, 2018 at 18:39
-
2Yes, it is still an MVC project. Your Data Access Layer, Business Layer and Entity Layer are all part of the Model.Robert Harvey– Robert Harvey2018年08月15日 19:26:22 +00:00Commented Aug 15, 2018 at 19:26
1 Answer 1
When you use an entity in a view, in a controller or anywhere, you must use it by namespace. For that reason, It is not important where entities locate.
You can delete Models folder and you can put entities in the other project.