简体   繁体   中英

How to Connect to SQL Server Database and Fetch datas by Just adding ADO.NET Entity Data model ASP.NET MVC 3

Im new to Asp.net MVC 3 and my boss wants me to remove the "SELECT/UPDATE/ DELETE SQL Query Statements" and recommend me to use ADO.NET Entity but my question is. . how can i map and fetch the datas in the database by just calling the DataContext. . Thanks!

  1. Right click on your Project and select add new Item. from Add New Item and select "ADO.net Entity Data model". Give the name and all necessary things, attach your DB and signing credentials. after finishing a .edmx file will add at your project.
  2. open the edmx file and right click on the design view and select "add Code Generation item". Add new Item panel appears. from the panel select "ADO.net DbContext Generator". give the name and add it.
  3. Crete a object of DbContext Class. use that DbContex Object methods to insert/Update/Delete command to do your job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM