
A library management enterprise system built using ASP.NET Core + Entity Framework Core + LINQ + MySQL. Provides REST endpoints for managing books, members and loans.
Introduction • Features • Tech Stack • Getting Started • API Endpoints • Documentation
LibAdminSystem is a lightweight library management system built with ASP.NET Core Minimal APIs, Entity Framework Core, and MySQL. It provides RESTful endpoints for managing core library operations such as tracking books, members, and loans.
The goal of this project is to serve as both:
-
A practical example of using modern .NET technologies (Minimal APIs, EF Core, LINQ) in a clean, modular design.
-
A foundation for building out more complex administrative systems where database backed CRUD operations are exposed through REST services.
-
CRUD operations for:
-
Books
-
Members
-
Loans
-
-
REST API endpoints with ASP.NET Core Minimal APIs
-
Entity Framework Core with MySQL provider
-
LINQ queries for flexible data access
-
Seed data on first run
Language: C# (.NET Core 9.0.x) + LINQ
Frameworks: ASP.NET Core, EF Core
Database: MySQL
ORM: Entity Framework Core
CI/CD: GitHub Actions
Install the following NuGet packages (if it doesnt get installed automatically):
-
Microsoft.EntityFrameworkCore
-
Pomelo.EntityFrameworkCore.MySql
-Pomelo
is the go-to EF Core provider for MySQL. -
Microsoft.EntityFrameworkCore.Tools
-
Microsoft.EntityFrameworkCore.Design
-
Swashbuckle.AspNetCore
- For Swagger REST API documentation support
- Clone the repo
git clone https://github.com/DivyenduDutta/LibAdminSystem.git
cd LibAdminSystem
- Ensure that your MySQL server is running and the proper connection string is mentioned in
appsettings.json
as below:
{
"ConnectionStrings": {
"LibAdminSystem": "<your MySQL connection string>"
}
}
See this regarding how to change MySQL server port.
-
Run
dotnet tool install --global dotnet-ef
to install dotnet-ef if you haven't already. -
Generate the EF migrations and create the MySQL database with the required tables (
Note
- Make sure to delete the existing Migrations folder as part of this repo before doing the below).
dotnet ef migrations add InitialCreate
dotnet ef database update
- Run
Program.cs
to seed the database with sample data on first run and to start the REST server. The REST services can be tested with theLibAdminSystem.http
file using Endpoints Explorer.
Run dotnet format LibAdminSystem.sln --verify-no-changes
to check first for formatting/linting errors.
Then either fix manually or run dotnet format LibAdminSystem.sln
Refer to LibAdminSystem.http for example JSON payloads for POST/PUT
Method | Endpoint | Description |
---|---|---|
GET | /api/books |
Get all books |
GET | /api/books/{id} |
Get a book by ID |
Method | Endpoint | Description |
---|---|---|
GET | /api/members/{id} |
Get a member by ID |
POST | /api/members/add |
Register a new member |
Method | Endpoint | Description |
---|---|---|
GET | /api/loans/{id} |
Get a loan by ID |
PUT | /api/loans/{id} |
Update details of a borrowed book |
DELETE | /api/loans/{id} |
Cancel a loan |
LibAdminSystem uses Swagger UI via Swashbuckle. This provides a full interactive web UI where we can test endpoints right from the browser.
Run Program.cs
and this will open up the API document UI at http://localhost:<port>/index.html
The following functionality is provided via Swagger:
-
API endpoints grouped by route
-
Request/response schemas auto-generated from the model classes
-
“Try it out” button to execute requests against the running service
classDiagram
class Book {
+int Id
+string BookTitle
+string Author
+int Year
+string Genre
+int CopiesAvailable
}
class Member {
+int Id
+string Name
+string Email
+DateTime JoinDate
}
class Loan {
+int Id
+int BookId
+int MemberId
+DateTime LoanDate
+DateTime? ReturnDate
}
Book "1" --> "*" Loan
Member "1" --> "*" Loan
flowchart TD
subgraph API[ASP.NET Core Minimal APIs]
A[REST Endpoints]
end
subgraph EF[Entity Framework Core]
B[DbContext]
C[LINQ Queries]
end
subgraph DB[MySQL Database]
D[(Books Table)]
E[(Members Table)]
F[(Loans Table)]
end
A --> B
B --> C
C --> D
C --> E
C --> F