Facette.EntityFrameworkCore
1.0.1
dotnet add package Facette.EntityFrameworkCore --version 1.0.1
NuGet\Install-Package Facette.EntityFrameworkCore -Version 1.0.1
<PackageReference Include="Facette.EntityFrameworkCore" Version="1.0.1" />
<PackageVersion Include="Facette.EntityFrameworkCore" Version="1.0.1" />
<PackageReference Include="Facette.EntityFrameworkCore" />
paket add Facette.EntityFrameworkCore --version 1.0.1
#r "nuget: Facette.EntityFrameworkCore, 1.0.1"
#:package Facette.EntityFrameworkCore@1.0.1
#addin nuget:?package=Facette.EntityFrameworkCore&version=1.0.1
#tool nuget:?package=Facette.EntityFrameworkCore&version=1.0.1
<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 mapping —
FromSource(),ToSource(), and LINQProjectiongenerated 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/ConvertBackmethods on[MapFrom] - Enum conversion — auto-detect enum↔string/int mismatches
- Nullable mode —
AllNullablefor PATCH DTOs,AllRequiredfor strict contracts - Copy attributes — forward data annotations from source to DTO
- CRUD presets —
FacettePreset.Create(no Id, no projection) andFacettePreset.Read(no ToSource) - Conditional mapping —
[MapWhen]for runtime-toggled property inclusion - Hooks —
OnAfterFromSource,OnBeforeToSource,OnAfterToSourcepartial methods - Inheritance — base/derived DTO hierarchies
- Multi-source mapping —
[AdditionalSource]to combine multiple source types - Expression mapping —
MapExpression<TResult>()rewrites DTO predicates to source expressions - EF Core integration —
ProjectToFacette()andWhereFacette()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 | 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 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. |
-
net10.0
- Facette.Abstractions (>= 1.0.1)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
-
net8.0
- Facette.Abstractions (>= 1.0.1)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
-
net9.0
- Facette.Abstractions (>= 1.0.1)
- Microsoft.EntityFrameworkCore (>= 8.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.0.1 | 46 | 3/2/2026 |