ArturRios.Data.Relational.Core 3.0.2

dotnet add package ArturRios.Data.Relational.Core --version 3.0.2
                    
NuGet\Install-Package ArturRios.Data.Relational.Core -Version 3.0.2
                    
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="ArturRios.Data.Relational.Core" Version="3.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ArturRios.Data.Relational.Core" Version="3.0.2" />
                    
Directory.Packages.props
<PackageReference Include="ArturRios.Data.Relational.Core" />
                    
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 ArturRios.Data.Relational.Core --version 3.0.2
                    
#r "nuget: ArturRios.Data.Relational.Core, 3.0.2"
                    
#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 ArturRios.Data.Relational.Core@3.0.2
                    
#: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=ArturRios.Data.Relational.Core&version=3.0.2
                    
Install as a Cake Addin
#tool nuget:?package=ArturRios.Data.Relational.Core&version=3.0.2
                    
Install as a Cake Tool

ArturRios.Data.Relational.Core

NuGet Docs License: MIT

The shared EF Core foundation of the ArturRios.Data toolkit: repository and unit-of-work abstractions, EfRepository, BaseDbContext, and the provider seam that lets you swap database engines without touching your data layer.

Every operation returns a DataOutput / ProcessOutput envelope, so infrastructure failures — including optimistic-concurrency conflicts — surface as errors on the result instead of unhandled exceptions.

This package is engine-agnostic on its own. Pair it with a provider package:

Provider package Engine
ArturRios.Data.Sqlite SQLite
ArturRios.Data.PostgreSql PostgreSQL (Npgsql)
ArturRios.Data.Dapper Raw-SQL read path (add-on)

Installation

dotnet add package ArturRios.Data.Relational.Core
dotnet add package ArturRios.Data.Sqlite          # or .PostgreSql

Requires .NET 10.0 or later.

Quick start

1. Define an entity:

using ArturRios.Data.Relational.Core;

public class Product : Entity          // or : VersionedEntity for optimistic concurrency
{
    public string Name { get; set; } = string.Empty;
    public decimal Price { get; set; }
}

2. Define a context deriving from BaseDbContext:

using ArturRios.Data.Relational.Core.Configuration;
using Microsoft.EntityFrameworkCore;

public class AppDbContext(DbContextOptions options) : BaseDbContext(options)
{
    public DbSet<Product> Products => Set<Product>();
}

3. Configure (appsettings.json, default section "ArturRios.Data.Core"):

{
  "ArturRios.Data.Core": {
    "DatabaseType": "PostgreSql",
    "ConnectionString": "Host=localhost;Database=mydb;Username=app;Password=secret;"
  }
}

4. Register the provider + the data layer (Program.cs):

using ArturRios.Data.PostgreSql;                       // brings AddPostgreSqlProvider()
using ArturRios.Data.Relational.Core.DependencyInjection;

builder.Services.AddPostgreSqlProvider();
builder.Services.AddDataConfigFromSettings<AppDbContext>(builder.Configuration, "ArturRios.Data.Core");

AddDataConfigFromSettings<TContext> registers your context, the repositories, and the unit of work. It validates eagerly that a provider matching the configured DatabaseType is registered, so misconfiguration fails at startup rather than on first query.

When configuration lives in environment variables rather than appsettings, call AddDataConfigFromEnvironment<TContext> with a name prefix instead of AddDataConfigFromSettings:

builder.Services.AddDataConfigFromEnvironment<AppDbContext>("ARTURRIOS_DATA");

It reads ARTURRIOS_DATA_DATABASETYPE (one of PostgreSql, MySql, SqLite) and ARTURRIOS_DATA_CONNECTIONSTRING; the appsettings section is not consulted on this path.

5. Inject and use:

using ArturRios.Data.Relational.Core.Interfaces;
using ArturRios.Data.Relational.Core.Transactions;
using ArturRios.Output;

public class ProductService(IAsyncRepository<Product> repo, IAsyncUnitOfWork unitOfWork)
{
    public async Task<int> CreateAsync(Product p)
    {
        DataOutput<int> result = await repo.CreateAsync(p);
        return result.Success ? result.Data : throw new InvalidOperationException(string.Join(", ", result.Errors));
    }

    public Task<DataOutput<int>> CreateTwoAtomicallyAsync(Product a, Product b) =>
        unitOfWork.ExecuteInTransactionAsync(async () =>
        {
            var first = await repo.CreateAsync(a);
            await repo.CreateAsync(b);
            return first.Data;
        });
}

What's registered

Service Implementation Lifetime
IReadOnlyRepository<T> / IRepository<T> EfRepository<T> Scoped
IAsyncReadOnlyRepository<T> / IAsyncRepository<T> EfRepository<T> Scoped
IUnitOfWork / IAsyncUnitOfWork EfUnitOfWork Scoped

Repository surface

Reads: Query() (a deferred IQueryable<T> escape hatch), GetAll(), GetById(int). Writes: Create, CreateRange, Update, UpdateRange, Delete, DeleteRange — each with an …Async counterpart taking a CancellationToken.

Transactions: ExecuteInTransaction(work) for the common case, or BeginTransaction() for an explicit handle you control.

Optimistic concurrency

Derive from VersionedEntity to get a [ConcurrencyCheck] ConcurrencyStamp. BaseDbContext regenerates it on every update, so a stale value fails the write and returns a concurrency error on the envelope instead of throwing.

Documentation

Licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET 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 (4)

Showing the top 4 NuGet packages that depend on ArturRios.Data.Relational.Core:

Package Downloads
ArturRios.Data.PostgreSql

PostgreSQL provider for ArturRios.Data

ArturRios.Data.Sqlite

SQLite provider for ArturRios.Data

ArturRios.Data.Dapper

Dapper read-only query path for ArturRios.Data

ArturRios.Util.Test

Test utilities for .NET projects: custom xUnit assertions and environment-aware test attributes, in-memory repository and scheduler fakes, and a base class for functional web API tests.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.2 36 7/24/2026
3.0.1 40 7/23/2026
3.0.0 95 7/23/2026
2.0.0 91 7/23/2026
1.0.1 113 7/15/2026
1.0.0 116 7/15/2026