REST API template with .NET 8, C#, and PostgreSQL. Designed for quick customization.
# PostgreSQL URI (auto-converts to Npgsql format)
export ConnectionStrings__DefaultConnection="postgresql://user:password@host:5432/database"
# OR key-value format
export ConnectionStrings__DefaultConnection="Host=localhost;Port=5432;Database=mydb;Username=postgres;Password=password"# Install packages and tools
dotnet restore
dotnet tool restore
# Create initial migration (commits schema to codebase)
cd WebAPI
dotnet ef migrations add InitialCreate
cd ..dotnet run --project WebAPI --urls "http://0.0.0.0:5000"API: http://localhost:5000/api/users
Swagger UI: http://localhost:5000/swagger
| Method | Endpoint | Body |
|---|---|---|
| GET | /api/users |
- |
| POST | /api/users |
{ name, email, phoneNumber } |
| PUT | /api/users/{id} |
{ name, email, phoneNumber } |
| DELETE | /api/users/{id} |
- |
- ✅ CRUD Operations
- 📧 Email & Phone Validation
- 🐘 PostgreSQL + EF Core
- 🔄 Dynamic DB Configuration
- 🎯 Repository Pattern
- 🌐 CORS Enabled (All origins allowed)
- 🚀 Auto-migration on startup
- 📚 Swagger/OpenAPI Documentation
- Rename
User.csto your entity (e.g.,Customer.cs,Product.cs) - Update entity properties as needed
- Update
IUserRepository→ICustomerRepository - Update
UserRepository→CustomerRepository - Update
UsersController→CustomersController - Update
AppDbContext.cs:DbSet<User> Users→DbSet<Customer> Customers - Create migration:
cd WebAPI && dotnet ef migrations add InitialCreate - Apply migration:
dotnet ef database update