Skip to main content

RA.Utilities.Data.EntityFramework

NuGet version NuGet Downloads Codecov Publish NuGet GitHub license

The primary purpose of the RA.Utilities.Data.EntityFramework package is to provide concrete implementations of the data access abstractions defined in RA.Utilities.Data.Abstractions. It uses Entity Framework Core to build a ready-to-use, generic data access layer.

In short, it's the "engine" that connects your application's abstract data access patterns (like the Repository and Unit of Work) to a real database using EF Core.

🔑 Key Components and Benefits

Tis package accelerates the setup of a data access layer by providing several key components:

1. Generic Repository Implementations:

  • RepositoryBase<T>: A full implementation of IRepositoryBase<T> that provides complete CRUD (Create, Read, Update, Delete) functionality out of the box.
  • ReadRepositoryBase<T>: A read-only repository that is optimized for querying data. It uses AsNoTracking() by default for better performance, which is ideal for CQS (Command Query Separation) patterns.
  • WriteRepositoryBase<T>: A write-only repository for command operations (Add, Update, Delete).

2. Dependency Injection Extensions:

It provides extension methods like AddRepositoryBase() to simplify the registration of these generic repositories in your application's DI container.

🧩 How It Fits into the Ecosystem

This package is a crucial part of the RA.Utilities ecosystem. It sits in the Infrastructure/Data Layer and depends on:

By using this package, you can avoid writing repetitive data access code and focus on your application's business logic, while still maintaining a clean, decoupled, and testable architecture.

⚡️ In short, it helps you:

  • Accelerate Development: It provides generic base classes (RepositoryBase, ReadRepositoryBase, WriteRepositoryBase) that handle all the common CRUD (Create, Read, Update, Delete) operations, so you don't have to write that boilerplate code yourself.
  • Promote Clean Architecture: By providing the implementation for the data access abstractions, it allows your application's business logic to depend on interfaces, not on a specific data technology like Entity Framework Core. This makes your code more decoupled, maintainable, and easier to test.

⭕️ Core Components

The package offers several key components to achieve this:

  • RepositoryBase<T>: A full generic repository with both read and write functionality.
  • ReadRepositoryBase<T>: A read-only version optimized for performance (AsNoTracking()), ideal for query operations in a CQRS architecture.
  • WriteRepositoryBase<T>`: A write-only version for add, update, and delete operations.

By using this package, you can quickly set up a robust and well-architected data access layer for your .NET applications.

🛠️ Installation

You can install the package via the .NET CLI:

dotnet add package RA.Utilities.Data.EntityFramework

Or through the NuGet Package Manager console:

Install-Package RA.Utilities.Data.EntityFramework

🔗 Dependencies