Discuss how to use the EF framework under VS2015

Source: Internet
Author: User
This article is mainly for you to introduce the VS2015 under the simple use of the EF framework method, with a certain reference value, interested in small partners can refer to

VS2015 How to use the EF framework in a simple way, the details are as follows

New MODEL1.EDMX File

Page reference Database Model1 Create the model file for the ad database as follows,

Find the following menu

Locate the database class name that you want to reference.

Referencing in a page background


Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.Web.UI.WebControls;    namespace webapplication4{public partial class WebForm1:System.Web.UI.Page {protected readonly tb_facegroup _context;  Private readonly adentities datesql = new Adentities (); protected void Page_Load (object sender, EventArgs e) {adentities db = new adentities ();//The class to be instantiated//Add action//tb_use   R dd = new Tb_user ();   Dd.id = "Ddsds"; Dd.   Wid = "DSDSSD"; Db.tb_user.   ADD (DD); Db.    SaveChanges ();--Change the above code to database//query//list<tb_user> Lstorder = new list<tb_user> ();   Tb_user Lstorder = new Tb_user (); Lstorder = Datesql.tb_user.    GroupBy (r = r.id = = "Ddsds"); var info = Datesql.tb_user. OrderByDescending (r = r.id = = "Ddsds");//.     FirstOrDefault (r = r.id = = "Ddsds"); Print the query results if (info.   Any ()) {foreach (var userentity in info) {Console.WriteLine (userentity.id + "----" + userentity.wid); }   }    }    }} 
Related Article

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.