PosInformatique.Foundations.PhoneNumbers.EntityFramework 1.0.0

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

PosInformatique.Foundations.PhoneNumbers.EntityFramework

NuGet version NuGet downloads

Introduction

This package provides Entity Framework Core integration for the PhoneNumber value object from PosInformatique.Foundations.PhoneNumbers.

It allows you to map PhoneNumber properties to a database column of SQL type PhoneNumber (backed by VARCHAR(16)), using a dedicated value converter.

Install

You can install the package from NuGet:

dotnet add package PosInformatique.Foundations.PhoneNumbers.EntityFramework

Features

  • Entity Framework Core support for the PhoneNumber value object
  • Simple extension method IsPhoneNumber() to configure properties
  • Maps PhoneNumber to a SQL column with type PhoneNumber (VARCHAR(16), non-Unicode)
  • Uses a ValueConverter to convert between PhoneNumber and its E.164 string representation

Use cases

  • Persist PhoneNumber in your EF Core entities without manual conversion logic
  • Keep strong typing in your domain model while storing normalized E.164 strings in the database
  • Enforce a consistent database schema for phone numbers (custom PhoneNumber type mapped to VARCHAR(16))

Examples

⚠️ To use IsPhoneNumber(), you must first define the SQL type PhoneNumber mapped to VARCHAR(16) in your database. For SQL Server, you can create it with:

CREATE TYPE MimeType FROM VARCHAR(16) NOT NULL;

Configure a PhoneNumber property

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

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

    public PhoneNumber Phone { get; set; } = default!;
}

public sealed class CustomerConfiguration : IEntityTypeConfiguration<Customer>
{
    public void Configure(EntityTypeBuilder<Customer> builder)
    {
        builder.Property(c => c.Phone)
               .IsPhoneNumber(); // Maps to SQL type PhoneNumber (VARCHAR(16))
    }
}

Resulting database schema

The IsPhoneNumber() extension configures the property as:

  • Non-Unicode (IsUnicode(false))
  • Maximum length: 16
  • Column type: PhoneNumber (which must be mapped in your database as VARCHAR(16))

For example, your database column should look like:

Phone PhoneNumber NOT NULL
-- where `PhoneNumber` is mapped to VARCHAR(16)

Value conversion

Under the hood, the extension uses a ValueConverter<PhoneNumber, string>:

  • When saving, PhoneNumber is converted to its E.164 string representation (via ToString()).
  • When loading, the stored string is parsed back to a PhoneNumber instance.

This ensures the database always stores the normalized E.164 value, while your code works with the strongly-typed PhoneNumber value object.

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.1.0-rc.2 45 1/26/2026
1.1.0-rc.1 50 1/23/2026
1.0.0 412 11/19/2025
1.0.0-rc.4 349 11/19/2025
1.0.0-rc.3 365 11/18/2025
1.0.0-rc.2 366 11/18/2025
1.0.0-rc.1 368 11/18/2025

1.0.0
 - Initial release with the support Entity Framework persitance for PhoneNumber value object.