OrionKey.EntityFrameworkCore 0.7.0

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

OrionKey.EntityFrameworkCore

Model-wide EF Core value-converter registration for OrionKey strongly-typed IDs.

OrionKey's source generator already emits a ValueConverter<TId, TValue> and a per-property HasOrionKeyConversion() helper for every [OrionId] struct when a project references EF Core. This package adds the model-wide call so you stop wiring those converters property by property.

Install

dotnet add package OrionKey.EntityFrameworkCore

Model-wide registration

Call UseOrionKeyConversions() once, at the end of OnModelCreating, after your entity types are configured. It discovers every [OrionId] property on the model and wires its converter.

using Moongazing.OrionKey.EntityFrameworkCore;

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Order>(b =>
    {
        b.HasKey(o => o.Id);
        // No per-property HasConversion calls needed for OrderId, CustomerId, ...
    });

    modelBuilder.UseOrionKeyConversions();
}

An id property that already has a converter (configured explicitly, or by an earlier call) is left untouched, so explicit configuration always wins over the convention.

ConfigureConventions

If you prefer the pre-convention route, ConfigureOrionKeyConversions() registers the generated converter for every [OrionId] type in the given assemblies (defaulting to the calling assembly):

protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
    configurationBuilder.ConfigureOrionKeyConversions(typeof(OrderId).Assembly);
}

Per-property

For explicit, fully trimming- and AOT-safe control, the generic per-property helper takes the id and its underlying primitive:

modelBuilder.Entity<Order>()
    .Property(o => o.Id)
    .HasOrionKeyConversion<OrderId, Guid>();

This complements the HasOrionKeyConversion() extension the generator emits in each id's own namespace.

AOT and trimming

UseOrionKeyConversions() and ConfigureOrionKeyConversions() discover id types and their members by reflection at model-build time, so they are annotated RequiresUnreferencedCode / RequiresDynamicCode. Under Native AOT or aggressive trimming, prefer the per-property HasOrionKeyConversion<TId, TValue>() (reflection-free) or the generated per-id converter directly.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 is compatible.  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. 
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.8.0 112 7/28/2026
0.7.0 96 7/20/2026