PosInformatique.Foundations.People.EntityFramework
1.0.0-rc.4
Prefix Reserved
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
<PackageReference Include="PosInformatique.Foundations.People.EntityFramework" Version="1.0.0-rc.4" />
<PackageVersion Include="PosInformatique.Foundations.People.EntityFramework" Version="1.0.0-rc.4" />
<PackageReference Include="PosInformatique.Foundations.People.EntityFramework" />
paket add PosInformatique.Foundations.People.EntityFramework --version 1.0.0-rc.4
#r "nuget: PosInformatique.Foundations.People.EntityFramework, 1.0.0-rc.4"
#:package PosInformatique.Foundations.People.EntityFramework@1.0.0-rc.4
#addin nuget:?package=PosInformatique.Foundations.People.EntityFramework&version=1.0.0-rc.4&prerelease
#tool nuget:?package=PosInformatique.Foundations.People.EntityFramework&version=1.0.0-rc.4&prerelease
PosInformatique.Foundations.People.EntityFramework
Introduction
This package provides Entity Framework Core extensions and value converters to persist the PosInformatique.Foundations.People value objects:
FirstNamestored asNVARCHAR(50)with proper conversion and comparisons.LastNamestored asNVARCHAR(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()andIsLastName()to configure EF Core properties forFirstNameandLastName. - Easy EF Core mapping for
FirstNameandLastNameproperties. - Maps to NVARCHAR(50), Unicode, non-fixed-length columns.
- Built on top of the core
FirstNameandFirstNamevalue 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
FirstNameproperty of thePersonEntityentity with:NVARCHAR(50)(Unicode) column length
- The
LastNameproperty of thePersonEntityentity 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.MaxLengthandLastName.MaxLength), ensuring alignment between code and database. - Converters/Comparers guarantee consistent persistence and querying semantics with the normalized value objects.
Links
| 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 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. |
-
net8.0
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- PosInformatique.Foundations.People (>= 1.0.0-rc.4)
-
net9.0
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.0)
- PosInformatique.Foundations.People (>= 1.0.0-rc.4)
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.