The MVC Architecture and multi-layer architecture are incompatible with the ORM framework. MVC database operations need to be performed through the Entity Framework, and multi-layer database operations need to be performed through the DAL layer. The recently completed project has implemented the coexistence of MVC and multiple layers. I would like to describe some experiences.
Why does MVC and multiple layers need to be bundled together? There are three reasons: first, the new project is a webmaster Tool website (www.youhuafenxi.com), which contains many query algorithms. We have accumulated in the BLL layer and can be used directly. Second, the elegance and cleanliness of MVC are especially suitable for our website. In the end, the exploration and use of new technologies are endless and will lag behind without learning.
The overall project is as follows:
After consideration, I decided to use multiple layers of data operations to discard the Entity Framework. The reason is: 1 team members seldom access Entity Framework. Originally, Mvc is a new thing and Entity Framework is introduced. There are too many new things in this project and the risk is too high. I always think that the proportion of new things in a project should not exceed 30%. 2 according to my friends, the performance of Entity Framework is not very good. Of course, this needs to be verified. 3 BLL is a public layer, code written in The BLL layer can be reused by other projects in the future, while code written in Entity Framework can only be used by this project.
MVC Architecture. The data entity is the directory of Models:
The multi-layer data entity is the Model layer:
What are the differences between the two models? The multi-layer Model exactly corresponds to the database fields one by one. It is very simple. It is a property. The MVC Model corresponds to the View business logic. This business logic may be associated with or not associated with the database, or even with multiple data tables, which may be complex, such as a List. However, for basic business logic, the form elements of the View can still correspond to Data Tables one by one. In this way, as long as the Mvc Model and multi-layer Model are correlated according to the same table field, you can use multi-layer data operations.
(To be continued)