DcsvIo.D2.Location.EntityFrameworkCore 0.1.1

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

DcsvIo.D2.Location.EntityFrameworkCore

Audience: backend .NET service engineers mapping DcsvIo.D2.Location value objects into EF Core entity models via infra IEntityTypeConfiguration<T>.

Per-VO complex-type and value-converter mapping helpers for the DcsvIo.D2.Location value objects (StreetAddress, AdminLocation, Coordinates). The helpers are called from the host's IEntityTypeConfiguration<T> implementation — the domain aggregate holds plain VO-typed properties and carries zero EF references.

Each helper, in one call:

  • Wires member value converters where needed (CountryCode, SubdivisionCode)
  • Applies HasMaxLength from FieldConstraints.* caps (plus the encoder-intrinsic geohash / plus-code caps)
  • Writes the per-field anonymize defaults via the fluent .Anonymize* API (DcsvIo.D2.DataGovernance.EntityFrameworkCore)

Ships no DbContext, no migrations, and no DI engine. The host owns all of those.


Install

dotnet add package DcsvIo.D2.Location.EntityFrameworkCore

Domain purity

Host aggregates hold VO-typed properties as plain CLR properties:

// Host domain aggregate — ZERO EF references.
public sealed class Sighting
{
    public required StreetAddress Where { get; init; }
    public AdminLocation? Admin { get; init; }
    public Coordinates? Coords { get; init; }
}

All EF mapping (converters, lengths, anonymize annotations) lives in the host's infra IEntityTypeConfiguration<T> class, which calls the toolkit helpers:

// Host infra layer — SightingConfiguration.cs (NOT in the toolkit; illustrative).
internal sealed class SightingConfiguration : IEntityTypeConfiguration<Sighting>
{
    public void Configure(EntityTypeBuilder<Sighting> b)
    {
        b.ComplexProperty(s => s.Where, cp => cp.MapStreetAddress());
        b.ComplexProperty(s => s.Admin, cp => cp.MapAdminLocation());
        b.ComplexProperty(s => s.Coords, cp => cp.MapCoordinates());
    }
}

Multi-field VO helpers (complex types)

Called from inside a b.ComplexProperty(…, cp => …) callback. No selector arg — the host already opened the ComplexPropertyBuilder<TComplex>; the helper decorates cp's members.

Helper VO Anonymize defaults
cp.MapStreetAddress() StreetAddress (Line1–5/HashId) Line1 → "[deleted]" (constant); Line2–5 → SetNull; HashId → cleared sentinel
cp.MapAdminLocation() AdminLocation (City/PostalCode/Subdivision/Country/HashId) City/PostalCode/Subdivision → SetNull; Country KEPT (coarse, no annotation); HashId → cleared sentinel
cp.MapCoordinates() Coordinates (Latitude/Longitude/Geohash/PlusCode/AccuracyMeters/HashId) Latitude/Longitude → "0" (constant, coerced to 0.0); Geohash/PlusCode → SetEmpty; AccuracyMeters → SetNull; HashId → cleared sentinel

Value converters encapsulated inside the helpers (the host never hand-wires them):

  • AdminLocation.SubdivisionIso31662CodeSubdivisionCode ↔ .Value string + HasMaxLength(8) (an empty stored value reads back as null, never SubdivisionCode(""))
  • AdminLocation.CountryIso31661Alpha2CodeCountryCode enum ↔ alpha-2 name string

Required-numeric anonymize coercion. Coordinates.Latitude / Longitude are required non-nullable double columns, so the V7 nullable guard forbids SetNull. They take a constant "0" string; the anonymization engine coerces it to 0.0 through the column's type mapping at erasure time. The required geohash / plus-code strings clear to empty (SetEmpty); only the nullable AccuracyMeters clears to null.

Same-VO-type-twice (e.g. home + work AdminLocation) works natively: the host calls MapAdminLocation() twice via two distinct host-property selectors. EF Core 10 prefixes columns by the owning-property path automatically (HomeLocation_City vs WorkLocation_City). The helpers never call HasColumnName, which preserves this default uniquification.


Per-VO anonymize-default table

VO Field Default Note
StreetAddress Line1 "[deleted]" Non-nullable — constant required
StreetAddress Line2–Line5 SetNull Nullable
StreetAddress HashId cleared sentinel ("v1." + 64×'0')
AdminLocation City/PostalCode/SubdivisionIso31662Code SetNull Nullable
AdminLocation CountryIso31661Alpha2Code KEPT Coarse-grained, not anonymized
AdminLocation HashId cleared sentinel
Coordinates Latitude/Longitude "0" (constant) Non-nullable numeric — coerced to 0.0
Coordinates Geohash/PlusCode SetEmpty Non-nullable string
Coordinates AccuracyMeters SetNull Nullable
Coordinates HashId cleared sentinel

Tombstone values are non-i18n literals — deliberately stable across locales.


Host responsibilities

  1. Register the anonymization engine: services.AddD2DataGovernance(…).
  2. Apply anonymization conventions: call ApplyAnonymizationConventions() on ModelConfigurationBuilder in ConfigureConventions.
  3. Implement IUserOwned + IAnonymizationTrackable on entities that carry anonymizable location data.

EF Core 10 complex-member-index limitation

For the EF Core 10 limitation on indexing ComplexProperty member columns (e.g. AdminLocation.City) and the CreateD2Index workaround, see DcsvIo.D2.EntityFrameworkCore.


Telemetry

No telemetry surface — mapping helpers are pure model-build-time calls with no runtime span or metric emission.

Edge cases / gotchas

  • SetNull on required numeric columns blockedCoordinates.Latitude / Longitude are non-nullable double columns. The V7 startup guard in DcsvIo.D2.DataGovernance blocks SetNull on non-nullable columns. Both fields take a constant "0" anonymization rule; the engine coerces "0" to 0.0 through the column's type mapping at erasure time.
  • Country field intentionally keptAdminLocation.CountryIso31661Alpha2Code carries no anonymization annotation. Country is coarse-grained and deliberately retained for analytics post-erasure.
  • Same-VO-type-twice (e.g. home + work AdminLocation) works natively. EF Core 10 prefixes columns by the owning-property path automatically. The helpers never call HasColumnName.

Configuration

No configuration — the helpers carry no tunable behavior. All caps come from the shared FieldConstraints codegen catalog.

Dependencies

  • DcsvIo.D2.Location (location/core/) — the StreetAddress / AdminLocation / Coordinates VO types being mapped
  • DcsvIo.D2.Validation.AbstractionsFieldConstraints.* length caps
  • DcsvIo.D2.DataGovernance.EntityFrameworkCore — the fluent .Anonymize* API
  • Microsoft.EntityFrameworkCore.RelationalComplexPropertyBuilder<T>, ComplexTypePropertyBuilder<T>, HasMaxLength, HasConversion
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

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.1 105 7/17/2026
0.1.0 108 7/17/2026