How to Make MVC and multi-layer architecture coexist in harmony (1)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.