Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer 1.2.2

dotnet add package Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer --version 1.2.2
                    
NuGet\Install-Package Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer -Version 1.2.2
                    
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="Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer" Version="1.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer" Version="1.2.2" />
                    
Directory.Packages.props
<PackageReference Include="Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer" />
                    
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 Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer --version 1.2.2
                    
#r "nuget: Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer, 1.2.2"
                    
#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 Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer@1.2.2
                    
#: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=Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer&version=1.2.2
                    
Install as a Cake Addin
#tool nuget:?package=Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer&version=1.2.2
                    
Install as a Cake Tool

Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer

Entity Framework Core + SQL Server integration for Brazilian.PrimitivesTypes.

Use this package when your domain model uses Brazilian primitive value objects and your persistence layer needs provider-aware EF Core mappings for SQL Server.

Install

dotnet add package Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer

The package references Brazilian.PrimitivesTypes and Microsoft.EntityFrameworkCore.SqlServer.

Quick start

Your domain model remains strongly typed:

using Brazilian.PrimitivesTypes;

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

    public Cpf Cpf { get; set; }

    public Email? Email { get; set; }

    public Cep Cep { get; set; }
}

Register the model-wide conventions in your DbContext:

using Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer;
using Microsoft.EntityFrameworkCore;

public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
    : DbContext(options)
{
    public DbSet<Customer> Customers => Set<Customer>();

    protected override void ConfigureConventions(
        ModelConfigurationBuilder configurationBuilder)
    {
        configurationBuilder.UseBrazilianPrimitiveTypesSqlServer();
    }
}

Referencing the package alone does not modify the EF model. The integration is explicitly opt-in.

Explicit property mappings

You can also configure individual properties:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Customer>(entity =>
    {
        entity.Property(customer => customer.Cpf)
            .HasBrazilianCpfSqlServer();

        entity.Property(customer => customer.Email)
            .HasBrazilianEmailSqlServer();

        entity.Property(customer => customer.Cep)
            .HasBrazilianCepSqlServer();
    });
}

What is stored

The database receives each primitive's canonical Value, not the display mask or original input.

Typical mappings use provider-aware varchar(n) columns, for example:

Cpf   VARCHAR(11)  NOT NULL,
Email VARCHAR(254) NULL,
Cep   VARCHAR(8)   NOT NULL

CLR nullability is preserved: nullable primitives map naturally to SQL NULL.

RG and State Registration

Rg and InscricaoEstadual support two explicit persistence strategies:

  • Context-free: stores only the canonical value.
  • State-aware: stores both the value and the Brazilian state context.

No state is inferred automatically. This keeps persistence behavior explicit and prevents accidental loss of domain context.

Migrations and schema

This package provides value conversions and SQL Server mapping metadata. Decisions such as indexes, unique constraints, alternate keys, and aggregate-specific rules remain the responsibility of the application.

Documentation

Package Purpose
Brazilian.PrimitivesTypes Core Brazilian value objects
Brazilian.PrimitivesTypes.EntityFrameworkCore.SqlServer EF Core + SQL Server integration
Brazilian.PrimitivesTypes.Dapper.SqlServer Dapper + SQL Server integration
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.2.2 93 8/28/2026
1.2.1 83 8/27/2026
1.2.0 92 8/25/2026
1.1.2 92 8/24/2026
1.1.1 92 8/24/2026