OrionKey.EntityFrameworkCore
0.8.0
dotnet add package OrionKey.EntityFrameworkCore --version 0.8.0
NuGet\Install-Package OrionKey.EntityFrameworkCore -Version 0.8.0
<PackageReference Include="OrionKey.EntityFrameworkCore" Version="0.8.0" />
<PackageVersion Include="OrionKey.EntityFrameworkCore" Version="0.8.0" />
<PackageReference Include="OrionKey.EntityFrameworkCore" />
paket add OrionKey.EntityFrameworkCore --version 0.8.0
#r "nuget: OrionKey.EntityFrameworkCore, 0.8.0"
#:package OrionKey.EntityFrameworkCore@0.8.0
#addin nuget:?package=OrionKey.EntityFrameworkCore&version=0.8.0
#tool nuget:?package=OrionKey.EntityFrameworkCore&version=0.8.0
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 | Versions 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- OrionKey (>= 0.8.0)
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.10)
- OrionKey (>= 0.8.0)
-
net9.0
- Microsoft.EntityFrameworkCore (>= 9.0.0)
- OrionKey (>= 0.8.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.