A simple RESTful API built with ASP.NET Core and PostgreSQL for managing users.
This project was created as a backend learning exercise to practice building APIs using C#, Entity Framework Core, and PostgreSQL.
- C#
- ASP.NET Core Web API
- Entity Framework Core
- PostgreSQL
- Swagger (OpenAPI)
- Git & GitHub
- DTO Pattern
- DataAnnotations
The API allows you to:
- Create a new user
- Retrieve all users
- Retrieve a user by ID
- Update user information
- Delete a user
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users | Get all users |
| GET | /api/users/{id} | Get a user by ID |
| POST | /api/users | Create a new user |
| PUT | /api/users/{id} | Update a user |
| DELETE | /api/users/{id} | Delete a user |
The project follows a simple layered structure:
Controllers → handle HTTP requests
DTOs → define API request and response models
Models → represent database entities
Data → Entity Framework database context
Migrations → database schema history
DTOs are used to separate the API contract from the internal data model and to enable validation using DataAnnotations.
This project uses PostgreSQL with Entity Framework Core for database management.
The database schema is managed using EF Core Migrations.
git clone https://github.com/Lucas-aos/user-management-api-dotnet.gitcd user-management-api-dotnetEdit the appsettings.json file and update the connection string with your PostgreSQL credentials.
Example:
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Port=5432;Database=YourDatabase;Username=postgres;Password=yourpassword"
}dotnet ef database updatedotnet runAccess Swagger in your browser:
http://localhost:5000/swagger
Below are examples of the API endpoints available through Swagger.
This project was built to practice:
- Building REST APIs with ASP.NET Core
- Using Entity Framework Core
- Connecting a .NET API to PostgreSQL
- Implementing CRUD operations
- Using Git and GitHub for version control
- Using DTOs to separate API contracts from domain models
- Applying validation with DataAnnotations
Lucas Albuquerque


