ASP. NET MVC4 + EF4.1 Series 1 Preface

Source: Internet
Author: User

The MVC4 + EF Series 1 mentioned above
I have been using MVC and EF for a while, but it is not long. Of course, I don't know much about MVC. I only want to consolidate my knowledge again, but also to record my learning experience. MVC3 has been used before, and MVC4 has been installed recently, so I learned from MVC4. Here I will use EF code first (I personally think that the generation of EF Model from the database can be completely removed from the field-based development, which is just my opinion played by Gao Lu ), in order to improve the learning efficiency, I will learn from the actual examples (I will use the course score management business that everyone often uses ). I plan to record my learning from a simple school course management case.
If you want to see any exceptions, please correct them. Thank you very much.
This school course management Demo is relatively simple, although simple, it is enough for me to use it to learn MVC4 and EF. No more nonsense. Let's get started ....... Not much said before the start to install EF4.1 here to give address http://www.microsoft.com/download/en/details.aspx? Displaylang = en & id = 8363 # overview download from Microsoft official website and MVC4.0. These two are essential. Because I used the new feature in EF4.1, that is, the DbContext object. ObjectContext before 4.1. Compared with ObjectContext, DbContext is simpler. Here is an example. In the DbContext API, you can use the Find () method to pass the Object ID to Find the object. At the same time, you can Find the object in the cache without having to go to the data, this improves performance, unlike Where () in ObjectContext (). the First () method still needs to pass through the database even if there is an object in the cache, which is detrimental to performance. I will not go into details here. In the following example, I will explain it in detail. This is more intuitive than just theory.
First, create an MVC4 project, as shown in:

 

Make sure that this MVC4 Web Application appears when you create a project. I am using MVC4 for vs2010 beat. Of course, this installation is relatively simple.

After mvc4 is selected, the selected page is displayed.

 

 

 

Compared with MVC3, the figure shows some new program frameworks added to MVC4. I don't know about these newly added things. I will try again later. Here I chose Internet Application. The selected page engine is Razor. I like the @ rule and do not need to close the rules in pairs, at the same time, the C # syntax rules are fully supported. At the same time, I created a namespace for the unit test for the program, so that I can perform the unit test if necessary. Here I will select the default MSUnityTest. Such an MVC4 program is simply set up.

So the first battle warned. The first step is completed, not 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.