Myth.Repository.EntityFramework
3.0.4-preview.16
See the version list below for details.
dotnet add package Myth.Repository.EntityFramework --version 3.0.4-preview.16
NuGet\Install-Package Myth.Repository.EntityFramework -Version 3.0.4-preview.16
<PackageReference Include="Myth.Repository.EntityFramework" Version="3.0.4-preview.16" />
<PackageVersion Include="Myth.Repository.EntityFramework" Version="3.0.4-preview.16" />
<PackageReference Include="Myth.Repository.EntityFramework" />
paket add Myth.Repository.EntityFramework --version 3.0.4-preview.16
#r "nuget: Myth.Repository.EntityFramework, 3.0.4-preview.16"
#:package Myth.Repository.EntityFramework@3.0.4-preview.16
#addin nuget:?package=Myth.Repository.EntityFramework&version=3.0.4-preview.16&prerelease
#tool nuget:?package=Myth.Repository.EntityFramework&version=3.0.4-preview.16&prerelease
Myth.Repository.EntityFramework
It is a .NET library for defining database access repositories using Entity Framework.
⭐ Features
- Definition of base context
- Automatic reading of entity mapping files
- Writing implementation
- Implementation of reading using expressions
- Implementation of reading using specification
- Work with transactions
- Automatic repository registration with dependency injection
🔮 Usage
To use it, simply inherit the created context from BaseContext. After that, just create the repositories by passing it as a parameter.
🕶️ Reading'
Several methods can be used to read:
GetProviderName: Returns the database connection providerAsQueryable: Returns a collection for execution in the databaseAsEnumerable: Returns a collection for execution in memory]ToListAsync: Returns all items in the collectionWhere: Returns the collection with a filterSearchAsync: Returns the filtered collectionSearchPaginatedAsync: Returns the filtered and paginated collectionCountAsync: Counts the items in the collectionAnyAsync: Checks if any item in the collection meets a requirementAllAsync: Checks whether all items in the collection meet a requirementFirstOrDefaultAsync: Returns the first item in the collectionLastOrDefaultAsync: Returns the last item in the collection
✍️ Writing
The following methods can be used for writing:
AddAsync: Adds an item to the collectionAddRangeAsync: Adds multiple items to the collectionRemoveAsync: Removes an item from the collectionRemoveRangeAsync: Removes multiple items from the collectionUpdateAsync: Updates a collection itemUpdateRangeAsync: Updates multiple items in the collectionAttachAsync: Attach an item to the collectionAttachRangeAsync: Attach multiple items to the collectionSaveChangesAsync: Saves all changesExecuteSqlRawAsync: Executes a query in the database
🪄 Unit of work
The entity's independent functionalities are as follows:
SaveChangesAsync: Saves all changesExecuteSqlRawAsync: Executes a query in the databaseBeginTransactionAsync: Starts a transactionCommitAsync: Executes all transaction changesRollbackAsync: Undoes transaction changesCreateSavepointAsync: Creates a transaction checkpointRollbackToSavepointAsync: Returns to a transaction checkpoint
🚀 Dependency Injection Registration
The library provides automatic repository registration for simplified dependency injection setup.
Auto-Registration Methods
AddRepositories(): Automatically registers all repository implementations found in application assembliesAddRepositoriesFromAssembly(assembly): Registers repositories from a specific assemblyAddRepository<TInterface, TImplementation>(): Manually registers a specific repositoryAddUnitOfWork<TUnitOfWork>(): Registers a Unit of Work implementation
Basic Usage
// Program.cs - ASP.NET Core
var builder = WebApplication.CreateBuilder(args);
// Add Entity Framework DbContext
builder.Services.AddDbContext<MyContext>(options =>
options.UseSqlServer(connectionString));
// Automatically register ALL repositories
builder.Services.AddRepositories();
var app = builder.BuildApp(); // Use BuildApp() instead of Build()
Advanced Configuration
// Custom service lifetime
builder.Services.AddRepositories(ServiceLifetime.Transient);
// Register from specific assembly
builder.Services.AddRepositoriesFromAssembly(typeof(UserRepository).Assembly);
// Manual registration
builder.Services.AddRepository<IUserRepository, UserRepository>();
// Register Unit of Work
builder.Services.AddUnitOfWork<MyUnitOfWork>();
Repository Implementation Example
// 1. Create your repository interface
public interface IUserRepository : IReadWriteRepositoryAsync<User> {
// Add custom methods if needed
}
// 2. Create your repository implementation
public class UserRepository : ReadWriteRepositoryAsync<User>, IUserRepository {
public UserRepository(MyContext context) : base(context) { }
// Implement custom methods if needed
}
// 3. The repository will be automatically registered by AddRepositories()
Usage in Controllers/Services
[ApiController]
public class UsersController : ControllerBase {
private readonly IUserRepository _repository;
public UsersController(IUserRepository repository) {
_repository = repository;
}
[HttpGet]
public async Task<IEnumerable<User>> GetUsers() {
return await _repository.ToListAsync();
}
}
Registration Behavior
- Service Lifetime: Scoped by default (recommended for repositories)
- Interface Priority: EntityFramework-specific interfaces are registered before base interfaces
- Test Filtering: Types with "Test", "Mock", "Fake", or "Stub" in their names are automatically excluded
- Generic Types: Generic type definitions are automatically excluded
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.6)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.6)
- Myth.DependencyInjection (>= 3.0.4-preview.16)
- Myth.Repository (>= 3.0.4-preview.16)
- Myth.Specification (>= 3.0.4-preview.16)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Myth.Repository.EntityFramework:
| Package | Downloads |
|---|---|
|
Harpy.Domain
Basis for the domain layer of the Harpy Framework |
|
|
Harpy.Context
Basis for the context layer of the Harpy Framework |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.4.0-preview.8 | 83 | 3/12/2026 |
| 4.4.0-preview.7 | 59 | 3/12/2026 |
| 4.4.0-preview.6 | 83 | 2/20/2026 |
| 4.4.0-preview.5 | 64 | 2/19/2026 |
| 4.4.0-preview.4 | 63 | 2/18/2026 |
| 4.4.0-preview.3 | 68 | 2/18/2026 |
| 4.4.0-preview.2 | 77 | 2/17/2026 |
| 4.4.0-preview.1 | 70 | 2/14/2026 |
| 4.3.0 | 155 | 2/1/2026 |
| 4.3.0-preview.3 | 73 | 2/1/2026 |
| 4.3.0-preview.2 | 162 | 12/22/2025 |
| 4.2.1-preview.1 | 660 | 12/2/2025 |
| 4.2.0 | 481 | 11/30/2025 |
| 4.2.0-preview.1 | 97 | 11/29/2025 |
| 4.1.0 | 389 | 11/27/2025 |
| 4.1.0-preview.3 | 160 | 11/27/2025 |
| 4.1.0-preview.2 | 153 | 11/27/2025 |
| 4.1.0-preview.1 | 157 | 11/26/2025 |
| 4.0.1 | 220 | 11/22/2025 |
| 3.0.4-preview.16 | 108 | 11/1/2025 |