A simple CRUD (Create, Read, Update, Delete) RESTful API built with ASP.NET Core Web API and Entity Framework Core. This project is part of my learning journey into backend development with ASP.NET Core, focusing on clean architecture, data modeling, filtering, pagination, and service-based design.
A learning project focused on ASP.NET Core Web API + Entity Framework Core + SQL Server. It demonstrates how to build a structured API with Controllers, Services, Models, filtering, and pagination.
- CRUD operations for Products
- Create operation for Categories
- Pagination support for product listing
- Filtering products using query parameters
- Separation of concerns using Services layer
- Entity Framework Core with Code-First Migrations
- ASP.NET Core 8.0 Web API
- Entity Framework Core (Code-First + Migrations)
- SQL Server
- Swagger / OpenAPI (for API testing)
- Visual Studio 2026
- Clone the repository:
git clone https://github.com/Alireza-Jafari-tech/ASP.NET-Core-Product-Managment-Web-API.git
cd ASP.NET-Core-Product-Managment-Web-API- Update the connection string in
appsettings.json:
"ConnectionStrings": {
"DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=ProductDb;Trusted_Connection=True;TrustServerCertificate=True"
}- Apply migrations and create the database:
dotnet ef database update- Run the application:
dotnet run- Open Swagger in browser:
http://localhost:5164/swagger
(or the port shown in your console)
/Controllers
CategoryController.cs → API endpoints for category CRUD operations
ProductController.cs → API endpoints for product CRUD operations
/Data
AppDbContext.cs → Entity Framework Core DbContext configuration
/Models
Product.cs → Product entity
Category.cs → Category entity
PaginationParams.cs → Pagination parameters (page number, page size)
ProductFilter.cs → Filtering logic for products (query-based filtering)
/Services
ProductService.cs → Business logic for products
CategoryService.cs → Business logic for categories
/Migrations
→ EF Core migration files for database versioning
Program.cs
→ Application startup configuration (services, middleware, routing)
appsettings.json
→ Database connection string and app configuration
testApi.http
→ HTTP request samples for testing API endpointsYou can test the API using:
- Swagger UI
- Postman
- Any REST client
-
GET /api/Product→ Get all products with pagination (request body usesPaginationParams) -
GET /api/Product/{id}→ Get product by id -
GET /api/Product/byCategory?categoryId=1→ Get products by category id -
POST /api/Product/filter→ Filter products usingProductFilter -
POST /api/Product/search?searchTerm=phone→ Search products by name -
POST /api/Product/Add→ Create a new product -
PUT /api/Product/update?productId=1→ Update an existing product -
DELETE /api/Product/delete?productId=1→ Delete a product
-
GET /api/Category→ Get all categories -
POST /api/Category/add→ Create a new category
- Understand ASP.NET Core Web API project structure
- Practice CRUD operations with Entity Framework Core
- Implement Service Layer pattern
- Work with pagination and filtering
- Learn database migrations
- Build clean and maintainable API code
- Practice RESTful API principles
The project includes a testApi.http file that allows you to test endpoints directly inside Visual Studio / VS Code using the built-in HTTP client.
Example:
GET https://localhost:5164/api/productsThis project is licensed under the MIT License.
See the LICENSE file for details.
This project is for learning purposes, but feel free to fork and improve it. Suggestions and pull requests are welcome.
Just say: “add swagger screenshots section” or “polish it for GitHub” 💪
