This repository contains a solution demonstrating two approaches for building a RESTful API: one using Entity Framework Core and the other using Dapper. Both projects are fully functional, interchangeable, and configured with Swagger for API documentation and testing. Each project functions independently, allowing users to select based on preference or requirements. Both projects also utilize .NET Aspire for orchestration and telemetry capture, enabling performance benchmarking between the two implementations.
This project demonstrates a RESTful API built with ASP.NET Core 8, Entity Framework Core and SQL Server. Swagger is utilized to document and test the API endpoints.
- Presentation: Interact with the API using Swagger UI.
- Business Logic: Handles operations such as creating a book entry and managing loans.
- Data Access: Uses Entity Framework Core for data management.
- CRUD Operations: Manage books, borrowers, and loans.
- Data Validation: Ensures data integrity.
- Swagger Documentation: Provides an easy way to understand and test API endpoints.
- You will need to manually configure a database connection, as the database used during the build is not connected due to hosting costs.
Entity Framework Core |
---|
![]() |
This project demonstrates a RESTful API built with ASP.NET Core 8, Dapper and SQL Server. It serves as a lightweight alternative to the EF Core-based API, providing a streamlined approach to data access.
- Presentation: Interact with the API using Swagger UI.
- Business Logic: Similar operations as the EF Core-based API but implemented with Dapper.
- Data Access: Uses Dapper for data management.
- CRUD Operations: Manage books, borrowers, and loans.
- Data Validation: Ensures data integrity.
- Swagger Documentation: Provides an easy way to understand and test API endpoints.
- As with the EF Core-based API, you will need to manually configure a database connection due to the absence of a connected database.
Dapper |
---|
![]() |
You can choose to run either project depending on your needs:
- Entity Framework Core Based API: Navigate to the
LibraryAPI.EFCore
project and set it as the startup project. - Dapper Based API: Navigate to the
LibraryAPI.Dapper
project and set it as the startup project.
Both projects are fully configured to run standalone and include Swagger for API documentation and testing. Ensure you have the necessary database configurations set up in the appsettings.json
file for the chosen project.
-
Clone the repository:
git clone https://github.com/g-s-c-code/LibraryAPI.git
-
Navigate to the desired project directory:
cd LibraryAPI/EFCore # or cd LibraryAPI/Dapper
-
Install the required dependencies:
dotnet restore
-
Create and configure
appsettings.json
with your database connection (nested in 'root'). -
Run the project:
dotnet run
-
Access Swagger UI at
http://localhost:5000/swagger
(port may vary).