Facette.EntityFrameworkCore 1.0.1

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

<p align="center"> <img src="docs/facette.png" alt="Facette logo" width="200" /> </p>

A C# source generator that auto-generates DTO mapping code from [Facette]-annotated partial records — zero reflection, zero runtime dependencies.

This project is entirely vibe coded with Claude Code.

Features

  • Compile-time mappingFromSource(), ToSource(), and LINQ Projection generated via Roslyn
  • Property control — Include/Exclude lists, [MapFrom] renaming, [FacetteIgnore]
  • Nested objects & collections — auto-detected nested DTOs with List<T>, arrays, HashSet<T>, ImmutableArray<T>
  • Flattening — convention-based (HomeAddressCity) and explicit dot-notation ([MapFrom("HomeAddress.City")])
  • Value conversions — custom Convert/ConvertBack methods on [MapFrom]
  • Enum conversion — auto-detect enum↔string/int mismatches
  • Nullable modeAllNullable for PATCH DTOs, AllRequired for strict contracts
  • Copy attributes — forward data annotations from source to DTO
  • CRUD presetsFacettePreset.Create (no Id, no projection) and FacettePreset.Read (no ToSource)
  • Conditional mapping[MapWhen] for runtime-toggled property inclusion
  • HooksOnAfterFromSource, OnBeforeToSource, OnAfterToSource partial methods
  • Inheritance — base/derived DTO hierarchies
  • Multi-source mapping[AdditionalSource] to combine multiple source types
  • Expression mappingMapExpression<TResult>() rewrites DTO predicates to source expressions
  • EF Core integrationProjectToFacette() and WhereFacette() extensions (no reflection)
  • 13 compile-time diagnostics — FCT001–FCT013 catch configuration errors early

Quick start

dotnet add package Facette.Abstractions
dotnet add package Facette

Define your model and DTO:

public class Employee
{
    public int Id { get; set; }
    public string FirstName { get; set; } = "";
    public string LastName { get; set; } = "";
    public string Email { get; set; } = "";
    public decimal Salary { get; set; }
    public string SocialSecurityNumber { get; set; } = "";
}

[Facette(typeof(Employee), "SocialSecurityNumber")]
public partial record EmployeeDto;

Use the generated code:

// Source → DTO
var dto = EmployeeDto.FromSource(employee);

// DTO → Source
var entity = dto.ToSource();

// LINQ projection (translates to SQL with EF Core)
var dtos = dbContext.Employees
    .Select(EmployeeDto.Projection)
    .ToListAsync();

Packages

Package Description
Facette.Abstractions Attributes ([Facette], [MapFrom], [MapWhen], etc.)
Facette Source generator (compile-time only)
Facette.EntityFrameworkCore EF Core extensions (ProjectToFacette, WhereFacette)

Documentation

Full documentation is available in the mdbook — run mdbook serve docs/ to browse locally.

Credits

Facette was heavily inspired by Facet and Mapperly.

License

See LICENSE for details.

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 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.0.1 46 3/2/2026