A .NET Core / .NET 9 Web API for managing a library system, backed by MS SQL Server.
This project is structured with clean architecture (Domain, Application, Infrastructure, API) and supports basic CRUD operations on books, authors, categories, publishers, etc.
LibraryApiSqlServer/
├── Library.Api/ # API / presentation layer (controllers, endpoints)
├── Library.Application/ # Application logic
│ ├── Services/ # Business services / use cases
│ └── DTOs/ # Data Transfer Objects, ViewModels
├── Library.Domain/ # Domain / core (entities, interfaces)
├── Library.Infrastructure/ # Data access, repository implementations, EF Core, DB context
├── LibraryApiSqlServer.sln
├── Program.cs
├── appsettings.json
├── appsettings.Development.json
└── README.md
- .NET 9 SDK or compatible .NET version
- SQL Server instance (local or remote)
- Docker Desktop for containerized setup (Optional)
- A tool like SQL Server Management Studio (SSMS) for DB inspection (Optional)
1. Clone the repository
git clone https://github.com/rashedulalam46/library-api-sqlserver.git
cd library-api-sqlserver2. Configure connection string
Open appsettings.json or appsettings.Development.json, and set up your ConnectionStrings:DefaultConnection to point to your SQL Server.
{
"ConnectionStrings": {
"ConString": "Server=YOUR_SERVER;Database=LibraryDb;User Id=…;Password=…;"
}
}
If you are using Docker, then use
{
"ConnectionStrings": {
"ConString": "Server=host.docker.internal;Database=LibraryDb;User Id=…;Password=…;"
}
}
3. Apply migrations / create database
Run the SQL script located in Library.Infrastructure/Data/DatabaseScript.sql to create the database and tables.
Alternatively, to create the database and tables using Entity Framework, run the following command in the Infrastructure project (or from the solution root):
dotnet ef database update
This will create the database and necessary tables.
4. Build & run the API
dotnet build
dotnet run
The default launch URL might be https://localhost:5001 (or as configured). Use a tool like Postman, curl, or HTTPie to test the endpoints.
These are sample endpoints — adjust according to actual implementation.
| Method | URL | Description |
|---|---|---|
| GET | /api/books | Get all books |
| GET | /api/books/{id} | Get book by ID |
| POST | /api/books | Create a new book |
| PUT | /api/books/{id} | Update an existing book |
| DELETE | /api/books/{id} | Delete a book by ID |
- Clean / layered architecture (Domain, Application, Infrastructure)
- Dependency Injection
- EF Core as data access layer
- DTOs / ViewModels for input/output
- Configuration-based connection strings
- Exception handling, validation, etc. (if implemented)
When you’re ready to deploy:
- Configure the production connection string in environment variables.
- Publish the project:
dotnet publish --configuration Release
- Deploy the resulting output to your server / host / container.
- Ensure the database is accessible and migrations are applied.
- Feel free to fork or suggest changes via pull requests.
- Add a LICENSE file if you have specific usage terms.
- Please document style, code conventions, etc., in a CONTRIBUTING.md.