Simple use of EF framework in VS2015, vs2015ef framework

Source: Internet
Author: User

Simple use of EF framework in VS2015, vs2015ef framework

Create a Model1.edmx File

Reference the following figure to create the model file of the AD database,

Find the following menu

 

Find the name of the database class to be referenced.

 

Reference in the background of the page

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_user dd = new tb_user (); // dd. ID = "ddsds"; // dd. wid = "dsdssd"; // db. tb_user.Add (dd); // db. saveChanges (); -- change the above Code to the 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 result 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.