Wiaoj.Identifiers.EntityFrameworkCore 0.1.0-alpha.9

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

Wiaoj.Identifiers.EntityFrameworkCore

Stores Wiaoj.Identifiers as bigint columns in Entity Framework Core, and generates keys for entities added without one.

Installation

dotnet add package Wiaoj.Identifiers.EntityFrameworkCore

This package depends on Wiaoj.Identifiers.Abstractions, not on the hosting package. An infrastructure project that maps entities doesn't need AddIdentifiers().

Usage

public sealed class ShopContext(DbContextOptions<ShopContext> options) : DbContext(options) {
    public DbSet<Customer> Customers => Set<Customer>();

    protected override void ConfigureConventions(ModelConfigurationBuilder builder) {
        builder.AddIdentifier<CustomerId>();
        builder.AddIdentifier<OrderId>();
    }
}

public sealed class Customer {
    public CustomerId Id { get; set; }        // bigint primary key, generated on add
    public OrderId? LastOrderId { get; set; } // nullable bigint
}

AddIdentifiersFromAssemblies(typeof(CustomerId).Assembly) registers every identifier type in an assembly instead. It uses reflection, so under trimming or Native AOT call AddIdentifier<TId>() for each type.

What is stored

The column holds Value, the Snowflake, as a 64-bit integer. The database never stores the text a codec writes. This means:

  • No codec needed: migrations, queries and reports work without a codec or key, and neither is installed to read or write rows.
  • Key changes don't touch data: changing the AES key, or switching between plain and AES, changes nothing in the database.
  • Order and indexing: columns sort by creation (the Snowflake order) and index like any bigint.

Keys

A primary key made of a single identifier property gets a value generator: an entity added with an empty key (IsEmpty) receives TId.New(), and a key you set yourself is kept.

A key is left alone when:

  • it is also a foreign key, as in a one-to-one relationship that shares the principal's key;
  • the model configures its generation explicitly, for example with ValueGeneratedNever().

Queries

Compare identifiers directly and the converter translates them:

await db.Orders.Where(o => o.CustomerId == customerId).ToListAsync();
await db.Orders.Where(o => ids.Contains(o.Id)).ToListAsync();
await db.Orders.Where(o => o.ReviewerId == null).OrderBy(o => o.Id).ToListAsync();

Don't use o.Id.Value inside a query. The provider sees the converted column, not the struct's members, so the expression can't be translated. Compare with an identifier instead.

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.0-alpha.9 0 9/21/2026
0.1.0-alpha.8 0 9/21/2026
0.1.0-alpha.7 38 9/18/2026
0.1.0-alpha.6 38 9/16/2026
0.1.0-alpha.5 41 9/16/2026
0.1.0-alpha.4 42 9/16/2026