ASP. NET MVC Learning path-6

Source: Internet
Author: User

This paper is to consolidate the foundation

The code first used above creates the database

This article uses the database generation model

This uses the ADO Entity Data Model to generate the model

Follow the instructions below to complete the operation

Here's a look at how to use this framework

Data access modifications are primarily implemented through context classes, which are in MyModel.Context.cs

   Public Partial classMydbentities:dbcontext { Publicmydbentities ():Base("name=mydbentities")        {        }            protected Override voidonmodelcreating (Dbmodelbuilder modelBuilder) {Throw Newunintentionalcodefirstexception (); }             PublicDbset<students> Students {Get;Set; } }

We can use this context class like this
 Public class Homecontroller:controller    {        //        // GET:/home/        Private  ReadOnly Mydbentities _db=New  mydbentities ();          Public actionresult Index ()        {                        return  View (_db. Students.tolist ());        }    }

Index view

@model ienumerable<mvcdemo9.models.students>@{    "Index";} @{    foreach (var in Model)    {        <p> @value. Studentname</p>    }}

Run results

ASP. NET MVC Learning path-6

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.