How to perform CRUD operations of Employee Form in ASP.NET Core MVC Visual Studio 2022 step by step using scaffolding
Please Subscribe Youtube| Like Facebook | Follow Twitter
Video Tutorial: https://youtu.be/zM4V0dGD0QI
Introduction
In this article we will perform database CRUD operations of Employee form using scaffolding in visual studio 2022 (.Net 6.0) step by step.
![](https://imgaz.staticbg.com/images/oaupload/banggood/images/4C/DF/54993819-8c97-427c-b164-b9ed71c7ac04.jpg)
Steps
1. Open SQL Server and create database named Organization and SQL table named Employee with following queries
CREATE DATABASE Organization;
USE Organization;
CREATE TABLE Employee (
EmployeeID int NOT NULL IDENTITY(1,1) ,
DateOfBirth date NOT NULL,
EmployeeName varchar(100) not null,
FatheName varchar(100) not null,
PRIMARY KEY (EmployeeID)
);
2. Open Visual studio 2022 and create ASP.NET Core MVC Project
![](https://programtown.com/wp-content/uploads/2022/10/1-1-1024x576.png)
![](https://programtown.com/wp-content/uploads/2022/10/2-1-1024x576.png)
![](https://programtown.com/wp-content/uploads/2022/10/3-1-1024x576.png)
![](https://programtown.com/wp-content/uploads/2022/10/4-1-1024x576.png)
3. Install Required Nuget Packages
![](https://programtown.com/wp-content/uploads/2022/10/5-1024x576.png)
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
4. Create Model from Existing Database by using following command which contains your SQL server name and database name
Scaffold-DbContext "Server=DESKTOP-CTNFVJO\SQLEXPRESS;Database=Organization;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
5. Add Controller with views
![](https://programtown.com/wp-content/uploads/2022/10/6-1024x576.png)
![](https://programtown.com/wp-content/uploads/2022/10/7-1024x576.png)
![](https://programtown.com/wp-content/uploads/2022/10/8-1-1024x576.png)
6. Go to Program.cs and add following line
![](https://programtown.com/wp-content/uploads/2022/10/9-1024x576.png)
builder.Services.AddDbContext<OrganizationContext>(options => options.UseSqlServer(@"server=DESKTOP-CTNFVJO\SQLEXPRESS;Database=Organization;Trusted_Connection=True;"));
7. Run and test your application
![](https://programtown.com/wp-content/uploads/2022/10/10-1024x576.png)
![](https://programtown.com/wp-content/uploads/2022/10/11-1024x576.png)