Bokhandel is a robust console-based application for managing bookstore inventory and sales. It is built with Entity Framework Core and demonstrates a Layered Architecture by separating business logic into dedicated services.
The solution uses a clean separation of concerns:
Contains the core logic for processing data.
- AuthorService: Manages author details and associations.
- BookService: Handles book creation, updates, and deletion.
- InventoryService: Manages stock levels across different
Storelocations. - Service Pattern: Decouples the user interface from the data access layer.
Defines the database schema and context.
- Entity Framework Core: Uses
BokhandelContextto manage SQL Server connections. - Rich Domain Model: Includes entities for
Books,Authors,Publishers,Orders, andInventory.
The application models a complex relational database:
- Many-to-Many: Between
BooksandAuthors(a book can have multiple authors). - Inventory System:
Inventoryentity linksStoresandBookswith quantity tracking. - Sales:
OrderandOrderItementities to track transaction history.
Since this project was built using a Database First approach, you need to initialize the database schema using the provided SQL script.
-
Clone the repository
git clone https://github.com/Qian1507/Bokhandel.git
-
Set up the Database
- Locate the
script.sqlfile in the root directory. - Open SQL Server Management Studio (SSMS).
- Create a new database named
Bokhandel. - Run the script
script.sqlagainst this new database to create all tables (Books, Authors, Orders, etc.).
- Locate the
-
Configure Connection
- Open
Bokhandel/Models/BokhandelContext.cs. - Locate the
OnConfiguringmethod. - Update the Connection String to match your local SQL Server instance:
optionsBuilder.UseSqlServer("Server=localhost;Database=Bokhandel;Trusted_Connection=True;...");
- Open
-
Run the Application
- Open the solution in Visual Studio.
- Press
F5to start the Console Application.
Note: This project uses Entity Framework Core (Database First) scaffolding.