This project is a .NET 9 API built as an Aspire Playground, showcasing best practices for implementing:
- Generic Repository Pattern
- Unit of Work Pattern
- SQL Server integration with Entity Framework Core
The project serves as a learning and experimentation ground for advanced .NET development concepts, including clean architecture, reusable data access patterns, and efficient database transactions.
- Aspire Framework: Provides a robust foundation for building APIs.
- Generic Repository: A flexible data access abstraction for performing common CRUD operations.
- Unit of Work: Manages transactional consistency across multiple operations.
- Entity Framework Core: Simplifies interaction with SQL Server.
- .NET 9 API: Leverages the latest features and improvements in .NET 9.
The Generic Repository encapsulates common database operations like adding, updating, deleting, and retrieving entities. It promotes reusability and separation of concerns by abstracting data access logic from business logic. The Unit of Work ensures that all database changes made during a single operation are committed or rolled back as a unit, maintaining data integrity.
IRepository
Interface: Defines common data access methods.GenericRepository
Implementation: Provides a base class for data access.IUnitOfWork
Interface: Coordinates repository operations within a single transaction.UnitOfWork
Implementation: Manages repositories and commits changes to the database.
This project uses Entity Framework Core for ORM, providing a simple yet powerful mechanism for interacting with SQL Server databases.
- .NET 9 SDK
- SQL Server
- Visual Studio 2022 or a compatible IDE
-
Clone the repository:
git clone https://github.com/fkucukkara/aspireWorkshop.git
-
Restore dependencies:
dotnet restore
-
Apply migrations and update the database (just in case):
dotnet ef migrations add InitialCreate dotnet ef database update
-
Run the application:
cd src\aspireWorkshop.AppHost dotnet run
The connection string ConnectionStrings__sqlDb
is available in the Aspire Dashboard under the aspireworkshop-api project details section.
This project is licensed under the MIT License, which allows you to freely use, modify, and distribute the code. See the LICENSE
file for full details.