SparseTypes.EntityFrameworkCore
0.1.0-rc1.31
See the version list below for details.
dotnet add package SparseTypes.EntityFrameworkCore --version 0.1.0-rc1.31
NuGet\Install-Package SparseTypes.EntityFrameworkCore -Version 0.1.0-rc1.31
<PackageReference Include="SparseTypes.EntityFrameworkCore" Version="0.1.0-rc1.31" />
<PackageVersion Include="SparseTypes.EntityFrameworkCore" Version="0.1.0-rc1.31" />
<PackageReference Include="SparseTypes.EntityFrameworkCore" />
paket add SparseTypes.EntityFrameworkCore --version 0.1.0-rc1.31
#r "nuget: SparseTypes.EntityFrameworkCore, 0.1.0-rc1.31"
#:package SparseTypes.EntityFrameworkCore@0.1.0-rc1.31
#addin nuget:?package=SparseTypes.EntityFrameworkCore&version=0.1.0-rc1.31&prerelease
#tool nuget:?package=SparseTypes.EntityFrameworkCore&version=0.1.0-rc1.31&prerelease
SparseTypes.EntityFrameworkCore
Direct ChangeSet-to-entity mapping from DTOs onto tracked EF Core entities.
Status: production-usable mapping for issue #228. The accepted
ISparseChangeSet is both the strict write mask and the value source: only
changed members execute their setters, new values come from the typed
transitions, and there is no desired DTO argument. Apply never queries,
never calls SaveChanges, and never rebases. Orchestration (read-side
mapping, RebaseOnto, authorization, load/query, SaveChanges, transactions)
stays application-owned.
How it works:
- Declare
[SparseFragmentMapper<TEntity, TDto>]on a dedicated partial mapper class with an optional parameterlessConfigure()that uses the generatedMapmember. The ordinary generator emits conventional defaults (same-name scalars, nested objects, collection markers) into an external companion, implementsIEntityModelMapping<TEntity, TDto>on the mapper, and backsMapwith the builder active for the current plan build; explicit entries replace each default exactly once. Mappers with a parameterless constructor additionally gain anOrderMapper.Create(db.Model)shorthand. Keyed child collections useCollectionwith path-scopedElementchild overrides (omitted when the conventional child mappings suffice) plus explicit key, factory, removal (Delete/Detach/SoftDelete/Remove), and opt-inOrderpolicies.Mapis usable only during the synchronousConfigurecall; overlapping builds on one (singleton) instance serialize and leave nothing retained. - Build with
OrderMapper.Create(model)for partial mappers, orSparseEntityMapper<TEntity, TDto>.Create(mapping, model)otherwise. Creation validates the full coverage manifest against the EFIModel, so a dormant unmapped member fails here. Each call builds a fresh plan for that mapping instance; reuse the returned mapper for repeated applies. - Call
Apply(context, entity, accepted)with the tracked entity and the accepted/rebased change set, then save explicitly.ApplyWithResultadditionally correlates created children by path-scoped DTO temporary identity for the authoritative DTO and clientReconcile.
Safety defaults:
- Identity (primary/alternate keys), generated, concurrency-token, and shadow
members are never written unless explicitly allowed with
AllowWrite. Missingafter-state is not silent null: the default policy throws, and each member can opt intoIgnore,SetDefault, orSetNull.- Validation precedes any write: a deterministic failure leaves the entity
graph and the
ChangeTrackeruntouched. - Keyed collections sync by stable delta over loaded navigations only: unloaded navigations, unknown or foreign-parent keys, colliding identities, duplicate path-scoped temporaries, incomplete order evidence, and missing removal policies fail explicitly instead of guessing. A loaded navigation is not proof of completeness: filtered includes are unsupported for removal/reorder transitions.
- No unassigned sentinel is ever inferred from
default(TKey); assigned keys always take precedence over temporary lookup. - Changed declared-only collection paths, unkeyed sequences, and skip navigations are rejected with a diagnostic.
- Unmapped or ambiguous paths fail explicitly instead of disappearing.
See docs/efcore-mapping.md in the repository for the full API, lifecycle,
and the supported/unsupported matrix.
| 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.13)
- SparseTypes (>= 0.1.0-rc1.31)
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.0-rc1.182 | 43 | 11/13/2026 |
| 0.1.0-rc1.172 | 57 | 11/9/2026 |
| 0.1.0-rc1.40 | 76 | 10/27/2026 |
| 0.1.0-rc1.31 | 70 | 10/27/2026 |