Trellis.EntityFrameworkCore
3.0.0-alpha.100
This is a prerelease version of Trellis.EntityFrameworkCore.
dotnet add package Trellis.EntityFrameworkCore --version 3.0.0-alpha.100
NuGet\Install-Package Trellis.EntityFrameworkCore -Version 3.0.0-alpha.100
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="Trellis.EntityFrameworkCore" Version="3.0.0-alpha.100" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Trellis.EntityFrameworkCore" Version="3.0.0-alpha.100" />
<PackageReference Include="Trellis.EntityFrameworkCore" />
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 Trellis.EntityFrameworkCore --version 3.0.0-alpha.100
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Trellis.EntityFrameworkCore, 3.0.0-alpha.100"
#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 Trellis.EntityFrameworkCore@3.0.0-alpha.100
#: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=Trellis.EntityFrameworkCore&version=3.0.0-alpha.100&prerelease
#tool nuget:?package=Trellis.EntityFrameworkCore&version=3.0.0-alpha.100&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EF Core Integration
Thin integration layer that eliminates repetitive EF Core boilerplate when using Trellis value objects and Result<T>.
Installation
dotnet add package Trellis.EntityFrameworkCore
Quick Start
Register all Trellis value objects as scalar properties with a single line in ConfigureConventions:
using Trellis.EntityFrameworkCore;
public class AppDbContext : DbContext
{
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
// Scans your assembly for CustomerId, OrderStatus, etc.
// Also auto-scans Trellis.Primitives for EmailAddress, Url, PhoneNumber, etc.
// Also auto-maps Money properties as owned types (Amount + Currency columns)
configurationBuilder.ApplyTrellisConventions(typeof(CustomerId).Assembly);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// No HasConversion() boilerplate needed — just configure keys, indexes, constraints
modelBuilder.Entity<Customer>(b =>
{
b.HasKey(c => c.Id);
b.Property(c => c.Name).HasMaxLength(100).IsRequired();
b.Property(c => c.Email).HasMaxLength(254).IsRequired();
});
}
}
Money Properties — Zero Configuration
Money properties are automatically mapped as owned types with proper column naming and precision:
| Property Name | Amount Column | Currency Column | Amount Type | Currency Type |
|---|---|---|---|---|
Price |
Price |
PriceCurrency |
decimal(18,3) |
nvarchar(3) |
ShippingCost |
ShippingCost |
ShippingCostCurrency |
decimal(18,3) |
nvarchar(3) |
No OwnsOne calls needed — just declare Money properties on your entities and they work.
Result-Returning SaveChanges
// Returns Result<int> instead of throwing on conflicts or FK violations
var result = await context.SaveChangesResultAsync(ct);
// Returns Result<Unit> when you don't need the count
var result = await context.SaveChangesResultUnitAsync(ct);
| Exception | Error Type |
|---|---|
DbUpdateConcurrencyException |
ConflictError |
| Duplicate key (unique constraint) | ConflictError |
| Foreign key violation | DomainError |
Query Extensions
// Maybe-returning queries (no exception on missing)
Maybe<Customer> customer = await context.Customers
.FirstOrDefaultMaybeAsync(c => c.Id == customerId, ct);
// Result-returning queries
Result<Customer> customer = await context.Customers
.FirstOrDefaultResultAsync(
c => c.Id == customerId,
Error.NotFound("Customer", customerId),
ct);
// Specification pattern
var activeSpec = new ActiveCustomerSpec();
var activeCustomers = await context.Customers
.Where(activeSpec)
.ToListAsync(ct);
Related Packages
- Trellis.Results — Core
Result<T>andMaybe<T>types - Trellis.Primitives — Value object base classes and built-in types
- Trellis.DomainDrivenDesign —
Specification<T>,Entity<T>,Aggregate<T>
License
MIT — see LICENSE for details.
| Product | Versions 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.
-
net10.0
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.2)
- Trellis.Primitives (>= 3.0.0-alpha.100)
- Trellis.Results (>= 3.0.0-alpha.100)
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 |
|---|---|---|
| 3.0.0-alpha.100 | 29 | 3/4/2026 |
| 3.0.0-alpha.99 | 32 | 3/4/2026 |
| 3.0.0-alpha.98 | 38 | 3/3/2026 |
| 3.0.0-alpha.95 | 45 | 3/2/2026 |
| 3.0.0-alpha.94 | 46 | 3/2/2026 |
| 3.0.0-alpha.93 | 40 | 3/1/2026 |
| 3.0.0-alpha.92 | 47 | 2/28/2026 |