Wednesday 27 May 2020


CRUD operations using ASP.Net MVC with SQL server

Detail step by step procedure is given below

Step1:In SQL server,create database EmployeeDB. In this database create one table tbl_Employee  with following columns.


Step2:
Create Asp.Net MVC Project named as MVCCrud and select ‘Empty’ ‘MVC’ template as shown in fig below

Step3: Right click on Models folder & add AdoNet Data Model in which select ‘Code first from database’ as shown below


After adding data model our Models folder will look like this.

Note: Before adding controller build your solution once

Step4: Right click on Controller folder & add the following controller option
After selecting the above option a new window will open & add Model class & data context class name


This will add all insert update delete operations to our controller. Now run our application and see the result as below.
This is showing complete list of employee in table.


If you click on Create New  button then it will redirect to following page. Insert all details and then click Create button  employee list will update as shown below


The updated employee list is displaying below


Similarly edit update & delete operations also performed by clicking on edit & delete button 

Hope you like this article  

Posted By: pankaj_bhakre

No comments:

Post a Comment