PosInformatique.Foundations.People.EntityFramework 1.0.0-rc.4

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

PosInformatique.Foundations.People.EntityFramework

NuGet version NuGet downloads

Introduction

This package provides Entity Framework Core extensions and value converters to persist the PosInformatique.Foundations.People value objects:

  • FirstName stored as NVARCHAR(50) with proper conversion and comparisons.
  • LastName stored as NVARCHAR(50) with proper conversion and comparisons.

It exposes fluent configuration helpers to simplify mapping in your DbContext model configuration.

Install

You can install the package from NuGet:

dotnet add package PosInformatique.Foundations.People.EntityFramework

This package depends on the base package PosInformatique.Foundations.People.

Features

  • Provides an extension method IsFirstName() and IsLastName() to configure EF Core properties for FirstName and LastName.
  • Easy EF Core mapping for FirstName and LastName properties.
  • Maps to NVARCHAR(50), Unicode, non-fixed-length columns.
  • Built on top of the core FirstName and FirstName value objects.
  • Keeps domain normalization rules in the database boundary.

Examples

Configure model with IsFirstName and IsLastName

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PosInformatique.Foundations.People;

public sealed class PersonEntity
{
    public int Id { get; set; }

    // Persisted as NVARCHAR(50) using the FirstName converter and comparer
    public FirstName FirstName { get; set; } = null!;

    // Persisted as NVARCHAR(50) using the LastName converter and comparer
    public LastName LastName { get; set; } = null!;
}

public sealed class PeopleDbContext : DbContext
{
    public DbSet<PersonEntity> People => Set<PersonEntity>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        var person = modelBuilder.Entity<PersonEntity>();

        person.HasKey(p => p.Id);

        // Configure FirstName as NVARCHAR(50) with conversions
        person.Property(p => p.FirstName)
              .IsFirstName();

        // Configure LastName as NVARCHAR(50) with conversions
        person.Property(p => p.LastName)
              .IsLastName();
    }
}

This will configure:

  • The FirstName property of the PersonEntity entity with:
    • NVARCHAR(50) (Unicode) column length
  • The LastName property of the PersonEntity entity with:
    • NVARCHAR(50) (Unicode) column length

Saving and querying

var options = new DbContextOptionsBuilder<PeopleDbContext>()
    .UseSqlServer(connectionString)
    .Options;

using var db = new PeopleDbContext(options);

// Insert
var person = new PersonEntity
{
    FirstName = FirstName.Create("jean-paul"), // normalized to "Jean-Paul"
    LastName = LastName.Create("dupont")       // normalized to "DUPONT"
};
db.Add(person);
await db.SaveChangesAsync();

// Query (comparison and ordering use normalized string values via comparer/converter)
var ordered = await db.People
    .OrderBy(p => p.LastName)   // "DUPONT" etc.
    .ThenBy(p => p.FirstName)   // "Jean-Paul" etc.
    .ToListAsync();

Using With Separate Configuration Class

public sealed class PersonEntityConfiguration : IEntityTypeConfiguration<PersonEntity>
{
    public void Configure(EntityTypeBuilder<PersonEntity> builder)
    {
        builder.HasKey(p => p.Id);

        builder.Property(p => p.FirstName)
               .IsFirstName();

        builder.Property(p => p.LastName)
               .IsLastName();
    }
}

public sealed class PeopleDbContext : DbContext
{
    public DbSet<PersonEntity> People => Set<PersonEntity>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.ApplyConfiguration(new PersonEntityConfiguration());
    }
}

Notes

  • The mapping enforces the maximum length defined by the domain (FirstName.MaxLength and LastName.MaxLength), ensuring alignment between code and database.
  • Converters/Comparers guarantee consistent persistence and querying semantics with the normalized value objects.
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 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
1.0.0 413 11/19/2025
1.0.0-rc.4 340 11/19/2025
1.0.0-rc.3 349 11/18/2025
1.0.0-rc.2 345 11/18/2025
1.0.0-rc.1 346 11/18/2025

1.0.0
 - Initial release with the support Entity Framework persitance for FirstName and LastName value objects.