PosInformatique.Foundations.PhoneNumbers.EntityFramework
1.0.0
Prefix Reserved
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
<PackageReference Include="PosInformatique.Foundations.PhoneNumbers.EntityFramework" Version="1.0.0" />
<PackageVersion Include="PosInformatique.Foundations.PhoneNumbers.EntityFramework" Version="1.0.0" />
<PackageReference Include="PosInformatique.Foundations.PhoneNumbers.EntityFramework" />
paket add PosInformatique.Foundations.PhoneNumbers.EntityFramework --version 1.0.0
#r "nuget: PosInformatique.Foundations.PhoneNumbers.EntityFramework, 1.0.0"
#:package PosInformatique.Foundations.PhoneNumbers.EntityFramework@1.0.0
#addin nuget:?package=PosInformatique.Foundations.PhoneNumbers.EntityFramework&version=1.0.0
#tool nuget:?package=PosInformatique.Foundations.PhoneNumbers.EntityFramework&version=1.0.0
PosInformatique.Foundations.PhoneNumbers.EntityFramework
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
PhoneNumbervalue object - Simple extension method
IsPhoneNumber()to configure properties - Maps
PhoneNumberto a SQL column with typePhoneNumber(VARCHAR(16), non-Unicode) - Uses a
ValueConverterto convert betweenPhoneNumberand its E.164 string representation
Use cases
- Persist
PhoneNumberin 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
PhoneNumbertype mapped toVARCHAR(16))
Examples
⚠️ To use
IsPhoneNumber(), you must first define the SQL typePhoneNumbermapped toVARCHAR(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 asVARCHAR(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,
PhoneNumberis converted to its E.164 string representation (viaToString()). - When loading, the stored string is parsed back to a
PhoneNumberinstance.
This ensures the database always stores the normalized E.164 value, while your code works with the strongly-typed PhoneNumber value object.
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.PhoneNumbers (>= 1.0.0)
-
net9.0
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.0)
- PosInformatique.Foundations.PhoneNumbers (>= 1.0.0)
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.