Lyo.EntityReference.Models 1.0.9

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

Lyo.EntityReference.Models

Typed pair of logical entity kind (EntityType) and identifier string (EntityId), plus helpers for composite keys, JSON, opaque tokens, validation, and domain row shapes. No database or EF dependency.

Examples

Quick start

using System.Text.Json;
using Lyo.EntityReference.Models;

// From CLR type + Guid key (logical type from attribute or FullName)
var r = EntityRef.For<MyAggregate>(aggregate.Id);

// From entity instance + collection expression keys
var rEntity = EntityRef.For(person, p => [p.Id]);

// Logical type name only
var typeName = EntityRef.LogicalTypeName<MyAggregate>();

// Explicit type + id
var r2 = EntityRef.ForKey("Comic.Issue", issueId.ToString());

// JSON: register converter once
var options = new JsonSerializerOptions();
options.Converters.Add(new EntityRefJsonConverter());
JsonSerializer.Serialize(r, options); // {"entityType":"...","entityId":"..."}

// Relation endpoints (For = subject, From = actor)
var endpoints = EntityRelationBuilder.For<Volume>(volumeId).From<User>(userId);
EntityRelationValidation.RequireSubjectActor(endpoints.Subject, endpoints.Actor);

// Import provenance (owner id assigned on persist)
var source = EntitySourceRecord.From<EndatoPsPerson>(externalId, DateTime.UtcNow);
EntitySourceValidation.RequireSource(source);

// Map EntityRef to persisted string columns (Guid ids become "d290f1ee-6c54-4b01-90e6-d701748f0851")
var subjectId = EntityRefPersistedGuid.PersistedEntityId(subjectRef);

Concepts

  • EntityRef. Immutable value (readonly record struct) used at API boundaries. Constructors validate non-whitespace type and id.
  • Stable type names. Decorate CLR types with [EntityRefLogicalType("MyModule.Widget")] so persisted EntityType does not depend on Type.FullName.
  • Composite ids. Multiple key segments are sorted lexically and joined via EntityRefCompositeEncoding so literal : inside a segment stays unambiguous.
  • Relation vs source. Two persistence shapes:
  • Relations (favorite, note, comment, …). Subject + actor endpoints. Domain types use SubjectEntityType / ActorEntityId. PostgreSQL columns remain for_entity_* / from_entity_*.
  • Source links (*_source). External import provenance only: source_entity_type / source_entity_id + imported_at. Owner identity lives on the parent aggregate (for example person_id), not in EntityReference.
  • String persistence. Endpoint and source ids are nullable varchar at the DB. Stores and validation helpers enforce required values per use case. Callers still pass EntityRef at API boundaries. Use EntityRefPersistedGuid.PersistedEntityId() (or RequirePersistedGuid when comparing to row Guid primary keys) when EntityId is a single GUID string.
  • EntityRelationRow. Abstract domain mirror of a tenant-scoped relation row (subject/actor, visibility, soft-delete, metadata). Endpoint properties are string?, aligned with persisted columns.
  • EntitySourceRecord. Provenance shape: (EntityRef Source, DateTime ImportedAt). Use EntitySourceRecord.From(source, importedAt) at import. The owning aggregate id is set when persisting child *_source rows.
  • IEntitySourceDerived. Aggregates imported from external sources carry optional EntitySourceRecord? Source and LocallyModifiedAt when local edits diverge from the external source.

Debugging

EntityRef, EntityRelationRow, EntityRefOptions, and EntityRefActionContext use [DebuggerDisplay(...)] for compact watches. Several types override ToString() for readable logs, distinct from ToOpaqueToken() on EntityRef.

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Common (direct, lyo)
  • Lyo.Exceptions (direct, lyo)
  • System.Text.Json 10.0.5 (direct, microsoft, netstandard2.0)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 (transitive, microsoft)
  • System.Memory 4.6.3 (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (24)

Showing the top 5 NuGet packages that depend on Lyo.EntityReference.Models:

Package Downloads
Lyo.EntityReference.Postgres

Entity Framework Core base entity, configuration, and store helpers for canonical entity-ref rows on PostgreSQL.

Lyo.Config

Typed configuration definitions and per-entity bindings using flexible EntityRef references and JSON-backed values.

Lyo.Geolocation.Models

Geolocation models and data structures for the Lyo library suite.

Lyo.Audit

Audit trail library with AuditChange (entity change tracking) and AuditEvent (events to log). AuditChange has type assembly full name, old values, and changed properties. AuditEvent has event type, timestamp, actor, message, and metadata. Includes IAuditRecorder for pluggable storage.

Lyo.Geolocation

Geolocation utilities and services for the Lyo library suite.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.9 0 8/22/2026
1.0.6 93 8/20/2026
1.0.4 234 8/20/2026
1.0.3 244 8/19/2026
1.0.2 273 8/19/2026
1.0.1 489 8/18/2026
1.0.0 661 8/16/2026