Masterly.NonEmptyList.EntityFrameworkCore 2.0.0

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

Masterly.NonEmptyList.EntityFrameworkCore

Entity Framework Core integration for Masterly.NonEmptyList. Provides value converters, comparers, and extension methods to seamlessly store and retrieve NonEmptyList<T> and ImmutableNonEmptyList<T> collections in your database.

Installation

dotnet add package Masterly.NonEmptyList.EntityFrameworkCore

Features

  • JSON Value Conversion: Store NonEmptyList<T> as JSON strings in the database
  • Change Tracking: Proper change detection with custom value comparers
  • Relationship Support: Configure one-to-many and many-to-many relationships
  • Validation Interceptor: Ensure non-empty constraints on save
  • Query Extensions: Convert query results to NonEmptyList<T>
  • Auto-Configuration: Convention-based setup for all properties

Quick Start

JSON Value Conversion

public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public NonEmptyList<string> Tags { get; set; } = new("default");
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Product>()
        .Property(p => p.Tags)
        .HasNonEmptyListConversion();
}

One-to-Many Relationships

modelBuilder.Entity<Order>()
    .HasNonEmptyManyWithOne(
        o => o.Items,
        i => i.Order,
        i => i.OrderId);

Query Extensions

NonEmptyList<Product> products = await context.Products
    .Where(p => p.IsActive)
    .ToNonEmptyListAsync();

Documentation

For full documentation, see the Wiki.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 was computed.  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 was computed.  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
2.0.0 76 1/2/2026

v2.0.0:
- Initial release of Entity Framework Core integration
- NonEmptyListValueConverter and ImmutableNonEmptyListValueConverter for JSON serialization
- NonEmptyListValueComparer and ImmutableNonEmptyListValueComparer for change tracking
- HasNonEmptyListConversion and HasImmutableNonEmptyListConversion extension methods
- One-to-many relationship configuration: HasNonEmptyMany, HasNonEmptyManyWithOne
- Many-to-many relationship configuration: HasNonEmptyManyToMany
- Cascade delete and required navigation configuration
- SaveChanges validation interceptor via UseNonEmptyListValidation
- Query extensions: ToNonEmptyList, ToNonEmptyListAsync, ToNonEmptyListOrNull
- ApplyNonEmptyListConventions for auto-configuration
- Multi-targeting: .NET 6.0 and .NET 8.0