Step By Step Entity Framework With ADO.NET With MVC For Beginners

INTRODUCTION

In this article, we will learn the basics of Entity Framework by creating a sample application. This article is for those programmers who have some experience in creating ASP.NET applications, but are new to the Entity Framework .

Definition
  • It is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. 
  • It eliminates the need for most of the data-access code that developers usually need to write.
  • It retrieves and manipulates data as strongly typed objects
 

Procedure

Let's start with an introduction.
Step 1

 

Step 2

 

In this I selected Web API because I use it; you can also select MVC .

Then you will see a window like this:

 

In this window there are different inbuilt folders.

Step 3
  • Right click on project(First_MVC_ADO.Net).
  • Then click on add button; you will see a new window and click on New Item.
  • Select DATA in installation.
  • Then add New ado.net Entity data Model.
  • Name it whatever you want to give and click on add button.
 

Select this and click on next button then chose your data connection. After clicking on next you will see all tables from the databse.

Select table name which you created in database.

Here Mytable name was Employee then it created edmx diagram:



Here you can see the image.

In EmployeeEntitytt => you will see model of this Database.

Step 4

Now Add controller => ADD => controller.

=> choose controller MVC Controller with views, using entity framework.
=> Before adding New Controller Rebuild your solution. 

Step 5

Select Model class Name Which you already added in your solution:
 
After adding this you will see EmployeeController Which contains CRUD operations.

If you will run this solution:

 
ENTER NAME OF CONTROLER WITH URL CAREFULLY.

This window contains data which I created in databse (TABLE Employee)