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); } } } }}