MVC5 Insert Update Delete Using Entity Framework

Hello friends here I am explaining how to perform basic operation insert, update and delete in MVC5.

First create SQL table for insert , update , delete. here I am creating one employee details table and adding sample data as below image.

emp_sql

emp_sql1

Now create mvc application as below image.

emp_create1

emp_create2

emp_create3

After creating project solution explorer looks as below.

emp_vslook1

Now add data model as below image.

emp_add_model1

emp_add_model2

emp_add_model3

emp_add_model4

emp_add_model5

emp_add_model6

Your db model look as below image.

emp_add_model7

Now create controller that use to perform insert update delete as below image.

emp_controller1

emp_controller2

emp_controller4

emp_controller3

After adding controller visual studio automatically create methods of create new employee, delete, edit , update. solution explorer looks as below image.

emp_controller5

Now goto layout view and add one link for employee details as below image.

emp_lay

Add html helper hyperlink method as :

@Html.ActionLink (Link Text , Action Name , Controller Name)

emp_lay1

Your MVC insert , update , delete application is ready…………..run and test as, click on Employee link and your employee details will show.

emp_output

EMP_O2

You can add new , edit , delete using button in grid as ,

EMP_O3

EMP_O1

Add new employee details as

EMP_O5

You can use different grids as MVC Grid, Web Grid or other grids to display and also design the UI as per your need………………………..

Hope you enjoy it !!!!!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s