BookStoreApp is a C# application that manages a bookstore's inventory and allows users to add, delete, and order books. It utilizes the Entity Framework Core and a SQL Server database for data storage.
To run the BookStoreApp application, perform the following steps:
-
Open SSMS and create a SQL Server database. Then open the project using your preferred IDE and update the connection string in the
BookStoreDbContext
class to point to your database. Database Configuration. -
Make sure you have installed all important NuGet packages such as:
Microsoft.EntityFrameworkCore
,Microsoft.EntityFrameworkCore.SqlServer
,Microsoft.EntityFrameworkCore.Tools
-
Open the NuGet Package Management Console in your project (e.g. in Visual Studio select "Tools" -> "NuGet Package Manager" -> "Package Manager Console").
-
Type the following command to create a migration for the data model:
Add-Migration InitialCreate
. And after that type:Update-Database
-
Run the application, and the main window will appear, showing the list of books in the inventory.
-
Use the provided buttons to add, delete, or order books.
Please note that the application assumes a working database connection and suitable database schema is set up for the application to function properly.
The BookStoreDbContext
class is responsible for configuring the database connection. It uses Entity Framework Core's DbContextOptionsBuilder
to set up the SQL Server database connection string.
The connection string used in this project is as follows:
Data Source=ACERASPIRE5\\SQLEXPRESS;Initial Catalog=BookShop;Integrated Security=True;TrustServerCertificate=true
The OnModelCreating
method in the BookStoreDbContext
class defines the relationships between the entities using Fluent API. It configures the foreign key relationships between Book
and Author
, Book
and Category
, and Orders
and Book
.
The user interface of the application is built using Windows Presentation Foundation (WPF). The MainWindow
window contains a DataGrid
control that displays the list of books in the bookstore's inventory. Users can add, delete, and order books using the buttons provided in the interface.
The BookForm
window is used for adding or editing book details. It contains text boxes for entering the book's title, author, category, ISBN, description, price, and amount. Users can save the book details or cancel the operation.
The project utilizes the following technologies: