Skip to content

maronworks/asp-dotnet-core-postgresql

Repository files navigation

🧠 MyApi

MyApi is a lightweight, modular RESTful Web API built using ASP.NET Core and PostgreSQL. It features full CRUD functionality for a User entity, powered by Entity Framework Core. This project is ideal for learning how to integrate databases in .NET or for bootstrapping production-ready APIs.

License Platform Database ORM API Status


🔗 Repository

GitHub: https://github.com/ralphmarondev/asp-dotnet-core-postgresql


✨ Features

  • ✅ Full CRUD operations for User model
  • 🐘 PostgreSQL integration via EF Core
  • 🔄 Auto migrations and schema sync
  • 🧪 Easy testing with Postman or Swagger
  • 🧩 Clean and extensible architecture

🛠️ Getting Started

1. Clone the Repository

git clone https://github.com/ralphmarondev/asp-dotnet-core-postgresql.git
cd asp-dotnet-core-postgresql

🗃️ Setting Up the Database

Make sure PostgreSQL is installed and running.

1. Create the database

CREATE DATABASE myapi;

2. Update the connection string in appsettings.json

"ConnectionStrings": {
  "DefaultConnection": "Host=localhost;Database=myapi;Username=postgres;Password=yourpassword"
}

Replace yourpassword with your actual PostgreSQL password.


📦 Installing Dependencies

Install the required packages:

dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet tool install --global dotnet-ef

🚧 Running the App

1. Apply Migrations

dotnet ef migrations add InitialCreate
dotnet ef database update

2. Run the API

dotnet run

The app will be available at:

  • http://localhost:5220

🧪 Testing with Postman

Method URL Description Body
GET http://localhost:5220/api/user Fetch all users
GET http://localhost:5220/api/user/{id} Fetch user by ID
POST http://localhost:5220/api/user Create a user { "name": "Ralph Maron" }
PUT http://localhost:5220/api/user/{id} Update user by ID { "name": "Updated Name" }
DELETE http://localhost:5220/api/user/{id} Delete user by ID

Headers to include: Content-Type: application/json


📄 License

This project is licensed under the MIT License. See the LICENSE file for full details.


👤 Author

Ralph Maron Eda GitHub: @ralphmarondev


🤝 Contributing

Suggestions and contributions are welcome! Feel free to fork the repo, submit issues, or open pull requests. Let’s build clean and efficient backends together. ⚙️🚀

About

.Net Core + Postgresql

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages