A .NET 9 Web API for managing and searching products, featuring SQL Server and Elasticsearch integration.
- CRUD operations for products (Create, Read, Update, Delete)
- Search products using:
- Entity Framework (SQL Server)
- Elasticsearch (full-text search)
- Automatic product seeding (200,000+ fake products on first run)
- Response time middleware for performance tracking
- Swagger/OpenAPI documentation
- ASP.NET Core (.NET 9)
- Entity Framework Core (SQL Server)
- Elasticsearch (via NEST)
- Bogus (data seeding)
- Swagger (API docs)
- .NET 9 SDK
- SQL Server
- Elasticsearch (default:
http://localhost:9200
)
Edit PracticeApi/appsettings.json
to set your SQL Server connection string:
"ConnectionStrings": { "DefaultConnection": "Server=localhost;Database=SalesDB;User Id=sa;Password=abc@123;TrustServerCertificate=True;" }
- Restore dependencies:
dotnet restore
- Build and run the project:
dotnet run --project PracticeApi
- The API will automatically:
Apply database migrations
Seed the database with products (if empty)
Sync products to Elasticsearch
- Access Swagger UI at:
https://localhost:5001/swagger
POST /api/products/create
- Create a productPUT /api/products/update/{id}
- Update a productDELETE /api/products/delete/{id}
- Delete a productGET /api/products/getbyid/{id}
- Get product by IDGET /api/products/getall
- List all productsGET /api/products/searchef?query=...
- Search products (SQL)GET /api/products/searches?query=...
- Search products (Elasticsearch)
This project is provided for educational purposes.
Summary of content: • Describes the project, features, and tech stack. • Provides setup, configuration, and run instructions. • Lists main API endpoints. • Notes on licensing and usage. Let me know if you want to add usage examples or further details.