MinimalCleanArch.DataAccess 0.1.18-preview

This is a prerelease version of MinimalCleanArch.DataAccess.
dotnet add package MinimalCleanArch.DataAccess --version 0.1.18-preview
                    
NuGet\Install-Package MinimalCleanArch.DataAccess -Version 0.1.18-preview
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MinimalCleanArch.DataAccess" Version="0.1.18-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MinimalCleanArch.DataAccess" Version="0.1.18-preview" />
                    
Directory.Packages.props
<PackageReference Include="MinimalCleanArch.DataAccess" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MinimalCleanArch.DataAccess --version 0.1.18-preview
                    
#r "nuget: MinimalCleanArch.DataAccess, 0.1.18-preview"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MinimalCleanArch.DataAccess@0.1.18-preview
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MinimalCleanArch.DataAccess&version=0.1.18-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MinimalCleanArch.DataAccess&version=0.1.18-preview&prerelease
                    
Install as a Cake Tool

MinimalCleanArch.DataAccess

Entity Framework Core implementation for MinimalCleanArch (repositories, unit of work, specifications, DbContext helpers).

Version

  • Current preview: 0.1.18-preview (net9.0, net10.0). Latest stable: 0.1.17.

Why Use It

  • implement repository and unit-of-work patterns with EF Core instead of hand-rolling the infrastructure layer
  • use audited and soft-delete-aware base DbContexts that line up with the MCA domain abstractions
  • execute MCA specifications against EF Core without leaking query logic into handlers or controllers

When to Use It

  • use it when your application persists MCA domain models through EF Core and you want MCA repository/specification support on top
  • keep it in the infrastructure project where DbContext, migrations, and repository implementations live
  • skip it if you are using another persistence technology or you want to implement repository abstractions yourself

Dependency Direction

  • Depends on: MinimalCleanArch
  • Typically referenced by: infrastructure projects
  • Used by: API/host projects indirectly through your infrastructure project
  • Do not reference from: pure domain projects; application projects should normally depend on repository abstractions, not on this package

What's included

  • DbContextBase and IdentityDbContextBase with auditing/soft-delete support.
  • Repository<TEntity,TKey> and UnitOfWork implementations.
  • SpecificationEvaluator to translate specifications (including composed And/Or/Not) to EF Core queries and honor IsCountOnly, AsSplitQuery, and IgnoreQueryFilters.
  • DI extensions to register repositories/unit of work.
  • Common repository query methods such as AnyAsync, SingleOrDefaultAsync, and CountAsync(ISpecification<T>).
  • optional execution-context-aware base constructors for user and tenant-aware stamping

Usage

builder.Services.AddDbContext<AppDbContext>(opt => opt.UseSqlite("Data Source=app.db"));
builder.Services.AddScoped<DbContext>(sp => sp.GetRequiredService<AppDbContext>());
builder.Services.AddScoped<IUnitOfWork, UnitOfWork>();
builder.Services.AddScoped(typeof(IRepository<,>), typeof(Repository<,>));

If you need a custom unit of work and access to IServiceProvider while configuring the DbContext:

builder.Services.AddMinimalCleanArch<AppDbContext, AppDbContext>((sp, options) =>
{
    options.UseSqlite("Data Source=app.db");
});

Recommended DbContext base usage:

public sealed class AppDbContext : DbContextBase
{
    public AppDbContext(
        DbContextOptions<AppDbContext> options,
        IExecutionContext? executionContext = null)
        : base(options, executionContext)
    {
    }
}

Use the constructor overload that accepts IExecutionContext when you want audit stamping to flow from the current HTTP request or message-handler scope without overriding GetCurrentUserId().

public sealed class IncompleteHighPrioritySpec : BaseSpecification<Todo>
{
    public IncompleteHighPrioritySpec()
    {
        AddCriteria(t => !t.IsCompleted && t.Priority >= 3);
        ApplyOrderByDescending(t => t.Priority);
        UseNoTracking();
    }
}

// Compose and run
var dueToday = new DueTodaySpec();
var spec = new IncompleteHighPrioritySpec().And(dueToday);

var todos = await repository.GetAsync(spec, cancellationToken);
var hasAny = await repository.AnyAsync(spec, cancellationToken);
var total = await repository.CountAsync(spec, cancellationToken);

public sealed class DueTodaySpec : BaseSpecification<Todo>
{
    public DueTodaySpec() : base(t => t.DueDate != null && t.DueDate.Value.Date == DateTime.UtcNow.Date)
    {
    }
}

Use specifications through IRepository<TEntity, TKey> in application code. Treat SpecificationEvaluator as infrastructure-level plumbing for repository implementations and advanced EF integration points.

When using a locally built package, add a nuget.config pointing to your local feed (e.g., artifacts/nuget) before restoring.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.18-preview 0 3/12/2026
0.1.17 41 3/12/2026
0.1.17-preview 82 3/8/2026
0.1.16-preview 73 3/7/2026
0.1.15-preview 80 3/3/2026
0.1.14 92 3/2/2026
0.1.14-preview 83 3/1/2026
0.1.13-preview 87 2/28/2026
0.1.12-preview 100 2/22/2026
0.1.11-preview 98 12/27/2025
0.1.10-preview 94 12/27/2025
0.1.9-preview 124 12/21/2025
0.1.8-preview 225 12/15/2025
0.1.7 163 12/14/2025
0.1.7-preview 418 12/11/2025
0.1.6 438 12/9/2025
0.1.6-preview 536 12/9/2025
0.1.5 223 12/6/2025
0.1.4 199 5/26/2025
0.1.3 189 5/25/2025
Loading failed