Initial knowledge of MVC construction

Source: Internet
Author: User

The full name of MVC is the model View Controller, which is the abbreviation for the models-view-controller, which organizes the code with a method of business logic, data, interface display separation, and aggregates the business logic into a part. is a data persistence framework.

Model is the core of the framework. The data processing of the application is done here. The ability to operate on the database, view is the user interface to display and input data, and controller is to control the interaction between the model and the view, this can also be connected with the three layers we have previously learned.

The model layer can actually be seen as a layer B and D in layer three. Responsible for business logic processing and Operation database. And the view is the U layer.

In fact, when the first contact with this piece, it is very do not understand, do not know this call process and mechanism of action. So. I hit a sample in the video. For example, the following:

First build the MVC project:

After the project is named and a good path is selected. Click OK

Select an empty template to do so.

This allows you to create a good one MVC project.

After the project was built. Start connecting to the database. Before learning three layers or other content. Connecting to a database requires some configuration in the configuration file, and at the same time it is necessary to establish some connection statements in the program. After using MVC. There is no need to manually join the

Right-click the model directory and add the new item. the ADO Entity Data Model under Select data

Select Generate from Database model:

Click Next. The connection data interface appears, click New Connection, and then fill in the server name. Select SQL Server Authentication. After entering username and password. Select the name of the database you want to connect to.

for version numbers, 5.0 is generally used right now:


Next:

Choose the table you need, assuming you need a view or stored procedure. Tick on it. It is important to note that the "Determine the plural form of the generated object" is checked to help unify the table.


This makes it possible to establish a connection to the database. At the same time will be the initiative to generate their own configuration files, entities and so on.

In fact, this is basically the same as the previous content, just a change of form. But. Using such a method simplifies our operation. and improve reusability.

Summary:

The study of MVC is still in progress, the beginning of the time when contact, feel a little to start with, as the original contact three layers, all need hands-on practice. Just start, understand the general concept, and then through the sample to understand and grasp. The next article will write a sample to learn more about MVC.

Initial knowledge of MVC construction

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.