PosInformatique.Foundations.EmailAddresses.EntityFramework
1.0.0-alpha.4
Prefix Reserved
dotnet add package PosInformatique.Foundations.EmailAddresses.EntityFramework --version 1.0.0-alpha.4
NuGet\Install-Package PosInformatique.Foundations.EmailAddresses.EntityFramework -Version 1.0.0-alpha.4
<PackageReference Include="PosInformatique.Foundations.EmailAddresses.EntityFramework" Version="1.0.0-alpha.4" />
<PackageVersion Include="PosInformatique.Foundations.EmailAddresses.EntityFramework" Version="1.0.0-alpha.4" />
<PackageReference Include="PosInformatique.Foundations.EmailAddresses.EntityFramework" />
paket add PosInformatique.Foundations.EmailAddresses.EntityFramework --version 1.0.0-alpha.4
#r "nuget: PosInformatique.Foundations.EmailAddresses.EntityFramework, 1.0.0-alpha.4"
#:package PosInformatique.Foundations.EmailAddresses.EntityFramework@1.0.0-alpha.4
#addin nuget:?package=PosInformatique.Foundations.EmailAddresses.EntityFramework&version=1.0.0-alpha.4&prerelease
#tool nuget:?package=PosInformatique.Foundations.EmailAddresses.EntityFramework&version=1.0.0-alpha.4&prerelease
PosInformatique.Foundations.EmailAddresses.EntityFramework
Introduction
Provides Entity Framework Core integration for the EmailAddress
value object from
PosInformatique.Foundations.EmailAddresses.
This package enables seamless mapping of RFC 5322 compliant email addresses as strongly-typed properties in Entity Framework Core entities.
It ensures proper SQL type mapping, validation, and conversion to VARCHAR
when persisted to the database.
Install
You can install the package from NuGet:
dotnet add package PosInformatique.Foundations.EmailAddresses.EntityFramework
This package depends on the base package PosInformatique.Foundations.EmailAddresses.
Features
- Provides an extension method
IsEmailAddress()
to configure EF Core properties forEmailAddress
. - Maps to
VARCHAR(320)
database columns using the SQL typeEmailAddress
(you must define the SQL typeEmailAddress
mapped toVARCHAR(320)
in your database). - Ensures validation, normalization, and safe conversion to/from database fields.
- Built on top of the core
EmailAddress
value object.
Use cases
- Entity mapping: enforce strong typing for email addresses at the persistence layer.
- Consistency: ensure the same validation rules are applied in your entities and database.
- Safety: prevent invalid strings being stored in your database
Examples
⚠️ To use
IsEmailAddress()
, you must first define the SQL typeEmailAddress
mapped toVARCHAR(320)
in your database.
For SQL Server, you can create it with:
CREATE TYPE EmailAddress FROM VARCHAR(320) NOT NULL;
Example: Configure an entity
using Microsoft.EntityFrameworkCore;
using PosInformatique.Foundations;
public class User
{
public int Id { get; set; }
public EmailAddress Email { get; set; }
}
public class ApplicationDbContext : DbContext
{
public DbSet<User> Users => Set<User>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<User>()
.Property(u => u.Email)
.IsEmailAddress();
}
}
This will configure the Email
property of the User
entity with:
VARCHAR(320)
column length- Non-Unicode
- SQL column type
EmailAddress
- Bi-directional conversion between
EmailAddress
andstring
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net9.0
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.9)
- PosInformatique.Foundations.EmailAddresses (>= 1.0.0-alpha.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-alpha.4 | 33 | 9/27/2025 |
1.0.0-alpha.3 | 67 | 9/26/2025 |
1.0.0
- Initial release with the support Entity Framework persitance for EmailAddress value object.