RA.Utilities.Data.EntityFramework
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 ofIRepositoryBase<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 usesAsNoTracking()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:
RA.Utilities.Data.Abstractions: It implements the interfaces (IRepositoryBase, etc.) from this package.RA.Utilities.Data.Entities: It works with the entity base classes defined in this package.
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
RA.Utilities.Data.Abstractions: Provides the core interfaces (IRepository<T>,IUnitOfWork, etc.) that this package implements.Microsoft.EntityFrameworkCore: The underlying ORM used for the implementations.
📄️ ReadRepositoryBase
The ReadRepositoryBase class is a concrete implementation of a generic, read-only repository using Entity Framework Core.
📄️ WriteRepositoryBase
The WriteRepositoryBase class is a concrete implementation of a generic, write-only repository using Entity Framework Core.
📄️ RepositoryBase
The RepositoryBase class is a concrete implementation of a generic,
🗃️ Extensions
1 item
🗃️ Interceptors
1 item