Lyo.Tag.Postgres 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Lyo.Tag.Postgres --version 1.0.1
                    
NuGet\Install-Package Lyo.Tag.Postgres -Version 1.0.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="Lyo.Tag.Postgres" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lyo.Tag.Postgres" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Lyo.Tag.Postgres" />
                    
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.Tag.Postgres --version 1.0.1
                    
#r "nuget: Lyo.Tag.Postgres, 1.0.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 Lyo.Tag.Postgres@1.0.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=Lyo.Tag.Postgres&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Lyo.Tag.Postgres&version=1.0.1
                    
Install as a Cake Tool

Lyo.Tag.Postgres

PostgreSQL implementation of Lyo.Tag using Entity Framework Core. Persists tags to the tag.tag table (schema constant: PostgresTagOptions.Schema = "tag") with migrations support. Tags carry subject / optional actor (for_entity_* / from_entity_*) and are uniquely keyed by (for_entity_type, for_entity_id, name, tag_type, slug) per tenant.

PostgresTagStore implements ITagStore and Lyo.Health.IHealth (HealthCheckName = "tag-postgres"), so registering the store also wires up a liveness probe.

Examples

Usage

services.AddPostgresTagStore(new PostgresTagOptions {
    ConnectionString = "...",
    EnableAutoMigrations = true
});

Usage (2)

{
  "PostgresTag": {
    "ConnectionString": "Host=localhost;Database=lyo;...",
    "EnableAutoMigrations": true
  }
}

Usage (3)

services.AddPostgresTagStoreFromConfiguration(configuration);

Example: Tag a docket as urgent

// Add tag (idempotent – no-op if already exists)
await tagStore.AddTagAsync(
    EntityRef.ForGuid("Docket", docketId),
    "urgent",
    EntityRef.ForKey("User", userId.ToString()));

// Get all tags for an entity
var tags = await tagStore.GetTagsForEntityAsync(EntityRef.ForGuid("Docket", docketId));

// Find all dockets with "urgent" tag
var urgentDockets = await tagStore.GetEntitiesWithTagAsync("urgent", "Docket");

// Remove a tag
await tagStore.RemoveTagAsync(EntityRef.ForGuid("Docket", docketId), "urgent");

// Remove all tags from an entity
await tagStore.RemoveAllTagsForEntityAsync(EntityRef.ForGuid("Docket", docketId));

Migrations

export TAG_CONNECTION_STRING="Host=localhost;Database=lyo;Username=postgres;Password=postgres"
dotnet ef migrations add MigrationName --project Features/Tag/Lyo.Tag.Postgres

DI extensions

  • AddTagDbContextFactory(Action<PostgresTagOptions>) / AddTagDbContextFactory(PostgresTagOptions) — register only the IDbContextFactory<TagDbContext> (useful when consuming the schema directly from migrations or another store).
  • AddTagDbContextFactoryFromConfiguration(IConfiguration, string sectionName = PostgresTagOptions.SectionName) — same, but bound from configuration.
  • AddPostgresTagStore(Action<PostgresTagOptions>) / AddPostgresTagStore(PostgresTagOptions) — register the DbContext factory and the ITagStore singleton.
  • AddPostgresTagStoreFromConfiguration(IConfiguration, string sectionName = PostgresTagOptions.SectionName) — register the store using configuration binding. The default section name is PostgresTag.

Usage

Or with configuration:

Entity Reference

Uses Lyo.EntityReference.Models.EntityRef with generic or string-based creation:

// Generic: uses typeof(T).FullName, keys joined with ":"
var forDocket = EntityRef.For<Docket>(docketId);
var fromUser = EntityRef.For<User>(123);

// String-based
var forEntity = EntityRef.ForGuid("Docket", docketGuid);
var fromEntity = EntityRef.ForKey("User", "123");

Schema

  • tag.tagid (uuid), subject/actor columns (for_entity_type, for_entity_id, from_entity_type, from_entity_id — nullable varchar 128/256), name, slug, tag_type, tenant_id (uuid), lifecycle from EntityRelationEntityBase, plus tag-specific indexes
  • Unique index on (for_entity_type, for_entity_id, tag)
  • Index on (for_entity_type, for_entity_id)
  • Index on tag

Tenancy

PostgresTagStore accepts an optional Guid? tenantId on every read/write method (mirroring IFavoriteStore) and resolves it through TenancyResolver under the policy configured in PostgresTagOptions.Tenancy (inheriting from EntityRefOptions.Mode when unset). The tenant_id column is non-null, so only SingleTenantDefault and MultiTenantStrict modes are valid — SystemOnly is rejected at store construction. The store applies a WhereTenant filter on every query. See Lyo.EntityReference.Postgres for the full policy matrix and appsettings.json snippet.

{
  "PostgresTag": {
    "ConnectionString": "Host=localhost;Database=lyo;...",
    "Tenancy": { "Mode": "MultiTenantStrict" }
  }
}

Dependencies

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

  • Lyo.EntityReference.Models — (direct, lyo)
  • Lyo.EntityReference.Postgres — (direct, lyo)
  • Lyo.Exceptions — (direct, lyo)
  • Lyo.Health — (direct, lyo)
  • Lyo.Postgres — (direct, lyo)
  • Lyo.Tag — (direct, lyo)
  • Microsoft.EntityFrameworkCore 10.0.5 — (direct, microsoft)
  • Microsoft.EntityFrameworkCore.Design 10.0.5 — (direct, microsoft)
  • Microsoft.Extensions.Configuration.Binder 10.0.5 — (direct, microsoft)
  • Lyo.Common — (transitive, lyo)
  • Microsoft.EntityFrameworkCore.Relational 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Hosting.Abstractions 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Options 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Options.ConfigurationExtensions 10.0.5 — (transitive, microsoft)
  • Npgsql.EntityFrameworkCore.PostgreSQL 10.0.3 — (transitive, third-party)
  • System.Memory 4.6.3 — (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 — (transitive, microsoft, netstandard2.0)
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
1.0.2 0 8/19/2026
1.0.1 57 8/18/2026
1.0.0 83 8/16/2026