Skip to content

This project is a .NET 9 API built as an Aspire Playground, showcasing several best practices.

License

Notifications You must be signed in to change notification settings

fkucukkara/aspireWorkshop

Repository files navigation

Aspire Workshop

Overview

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.

Features

  • 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.

Description

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.

Key Components:

  1. IRepository Interface: Defines common data access methods.
  2. GenericRepository Implementation: Provides a base class for data access.
  3. IUnitOfWork Interface: Coordinates repository operations within a single transaction.
  4. 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.

Prerequisites

  • .NET 9 SDK
  • SQL Server
  • Visual Studio 2022 or a compatible IDE

How to Run

  1. Clone the repository:

    git clone https://github.com/fkucukkara/aspireWorkshop.git
  2. Restore dependencies:

    dotnet restore
  3. Apply migrations and update the database (just in case):

    dotnet ef migrations add InitialCreate
    dotnet ef database update
  4. Run the application:

    cd src\aspireWorkshop.AppHost
    dotnet run

How to Access the Database

The connection string ConnectionStrings__sqlDb is available in the Aspire Dashboard under the aspireworkshop-api project details section.

License

MIT License

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.

About

This project is a .NET 9 API built as an Aspire Playground, showcasing several best practices.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages