A full-featured CRUD (Create, View, Update, Delete) web application built with ASP.NET Core using Razor Pages and Entity Framework Core scaffolding.
Before running this application, make sure you have the following installed:
git clone https://github.com/yourusername/your-crud-app.git
cd your-crud-app
dotnet restore
dotnet build
Update the connection string
Open appsettings.json
and update the connection string to match your SQL Server instance:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=YourAppDb;Trusted_Connection=true;MultipleActiveResultSets=true;TrustServerCertificate=true;"
}
}
Run Entity Framework migrations
dotnet ef database update
If migrations don’t exist, create them first:
dotnet ef migrations add InitialCreate
dotnet ef database update
dotnet run
Access the application
Open your web browser and navigate to:
https://localhost:5001
(HTTPS)http://localhost:5000
(HTTP)PracticeWebApplication/
├── Connected Services/
├── Dependencies/
├── Properties/
├── wwwroot/
├── Controllers/
│ └── HomeController.cs
├── Migrations/
├── Models/
│ ├── EmployeeDbContext.cs
│ ├── EmployeeModel.cs
│ └── ErrorViewModel.cs
├── Views/
│ ├── Home/
│ │ ├── Create.cshtml
│ │ ├── Delete.cshtml
│ │ ├── Details.cshtml
│ │ ├── Edit.cshtml
│ │ ├── Index.cshtml
│ │ └── Privacy.cshtml
│ └── Shared/
│ ├── _ViewImports.cshtml
│ └── _ViewStart.cshtml
├── .gitattributes
├── .gitignore
├── appsettings.json
├── Program.cs
└── README.md
Index.cshtml
- Main listing pageCreate.cshtml
- Employee creation formEdit.cshtml
- Employee editing formDetails.cshtml
- Employee details viewDelete.cshtml
- Employee deletion confirmationPrivacy.cshtml
- Privacy policy pageThis structure follows standard ASP.NET Core MVC conventions with a clear separation of concerns between models, views, and controllers.
The application uses Razor Pages, but the following page routes are available:
GET /Home
- List all recordsGET /Home/Create
- Show create formPOST /Home/Create
- Create new recordGET /Home/Details/{id}
- Show record detailsGET /Home/Edit/{id}
- Show edit formPOST /Home/Edit/{id}
- Update recordGET /Home/Delete/{id}
- Show delete confirmationPOST /Home/Delete/{id}
- Delete recordUpdate the connection string in appsettings.json
to point to your database server.
The application supports different environments (Development, Staging, Production). Use appsettings.{Environment}.json
files for environment-specific settings.
dotnet clean
followed by dotnet build