Asp .Net MVC - SPLessons

ASP.Net MVC Entity Frame Work

Home > Lesson > Chapter 17
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

ASP.Net MVC Entity Frame Work

ASP.Net MVC Entity Frame Work

shape Description

Entity Framework is an OR Mapping Tool, which originally deal with the Conceptual Model rather than the Relational Model.
  • If one map Database to Entity Framework Model. Then, It creates a class with Database Name followed by Entities similar to LINQ.
  • The Database will find in the front end as a diagram.
  • To update the Data of the Employee Entities or Entities class, one should use a method "Save Changes".
  • There are no separate methods to Insert a Record or Delete a record from the Respective table.

How to create Entity FrameWork Model?

shape Step 1

Follow the below steps to work with Entity Framework. Create a new MVC Application.

shape Step 2

Go to Solution Explorer->Models->Right Click on the Models->Add->New Item as shown in the below figure.

shape Step 3

The Add New Item window will appear on screen. Go to Data->ADO.Net Entity Framework->Give the Name->Click on Add  as shown in the below figure.

shape Step 4

The Entity Framework Wizard will appear on screen. Select the Entity from the Database->Click on Next as shown in the below figure.

shape Step 5

Click the button New Connection and create a connection for data base to use the application, give the name for the connection and click Next, as shown in the below figure.

shape Step 6

Choose the Version of Entity framework, click Next to proceed as shown in the below figure.

shape Step 7

Select the Database object to be included in the model and click Finish button, as shown in the below figure.

shape Step 8

Diagram with the selected entity will appear on the screen, as shown in the below figure.

shape Step 9

Go to Solution Explorer-> see the folders which were newly created as shown in the below figure.

shape Step 10

Click on the Context file which is marked in the above figure in step 9, then the code will appear as shown in the below figure. One can see their own context file name as marked in the below figure.

shape Step 11

Click on the Model Class which is marked in the above figure in step 10, then the code will appear as shown in the below figure. One can see their own Model Class Name as marked in the below figure.