Ardalis.SmartEnum.EFCore 9.0.0
Ardalis.SmartEnum.EFCore
IMPORTANT This is the last MIT-licensed release of this library. Future releases will require a (potentially free) commercial license. Find out more
Entity Framework Core support for Ardalis.SmartEnum. Configures value conversions for every SmartEnum property in your model with a single call, so each one is stored as its Value.
Installation
dotnet add package Ardalis.SmartEnum.EFCore
Usage
Call ConfigureSmartEnum() at the start of ConfigureConventions in your DbContext:
using Ardalis.SmartEnum.EFCore;
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder.ConfigureSmartEnum();
}
Alternatively, call it at the end of OnModelCreating:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// ... your configuration
modelBuilder.ConfigureSmartEnum();
}
Upgrading from 8.x? The extension methods moved from the
SmartEnum.EFCorenamespace toArdalis.SmartEnum.EFCorein 9.0. Update yourusingdirective.
To configure a single property yourself, without this package, use a standard EF Core value conversion:
builder.Entity<Policy>()
.Property(p => p.PolicyStatus)
.HasConversion(
p => p.Value,
p => PolicyStatus.FromValue(p));
More information
See the SmartEnum project README for full documentation, including storing a SmartEnum in its own lookup table.
No packages depend on Ardalis.SmartEnum.EFCore.
See root package release notes
.NET 10.0
- Ardalis.SmartEnum (>= 9.0.0)
- Microsoft.EntityFrameworkCore (>= 10.0.15)
.NET 11.0
- Ardalis.SmartEnum (>= 9.0.0)
- Microsoft.EntityFrameworkCore (>= 11.0.0)