Facet.Extensions.EFCore
1.7.0
See the version list below for details.
dotnet add package Facet.Extensions.EFCore --version 1.7.0
NuGet\Install-Package Facet.Extensions.EFCore -Version 1.7.0
<PackageReference Include="Facet.Extensions.EFCore" Version="1.7.0" />
<PackageVersion Include="Facet.Extensions.EFCore" Version="1.7.0" />
<PackageReference Include="Facet.Extensions.EFCore" />
paket add Facet.Extensions.EFCore --version 1.7.0
#r "nuget: Facet.Extensions.EFCore, 1.7.0"
#:package Facet.Extensions.EFCore@1.7.0
#addin nuget:?package=Facet.Extensions.EFCore&version=1.7.0
#tool nuget:?package=Facet.Extensions.EFCore&version=1.7.0
Facet
"One part of a subject, situation, object that has many parts."
Facet is a C# source generator that lets you define lightweight projections (DTOs, API models, etc.) directly from your domain models — without writing boilerplate.
It generates partial classes, records, structs, or record structs with constructors, optional LINQ projections, and even supports custom mappings — all at compile time, with zero runtime cost.
What is Facetting?
Facetting is the process of defining focused views of a larger model at compile time.
Instead of manually writing separate DTOs, mappers, and projections, Facet allows you to declare what you want to keep — and generates everything else.
You can think of it like carving out a specific facet of a gem:
- The part you care about
- Leaving the rest behind.
Why Facetting?
- Reduce duplication across DTOs, projections, and ViewModels
- Maintain strong typing with no runtime cost
- Stay DRY (Don't Repeat Yourself) without sacrificing performance
- Works seamlessly with LINQ providers like Entity Framework
Key Features
- ✅ Generate classes, records, structs, or record structs from existing types
- ✅ Exclude fields/properties you don't want (create a Facetted view of your model)
- ✅ Include public fields (optional)
- ✅ Auto-generate constructors for fast mapping
- ✅ LINQ projection expressions
(Expression<Func<TSource,TTarget>>)
-:white_check_mark: Custom mapping viaIFacetMapConfiguration
Documentation
Quick Start
dotnet add package Facetusing Facet;
public class Person
{
public string Name { get; set; }
public string Email { get; set; }
public int Age { get; set; }
}
// Generate a DTO that excludes Email
[Facet(typeof(Person), exclude: nameof(Person.Email))]
public partial class PersonDto { }
var person = new Person { Name = "Alice", Email = "a@b.com", Age = 30 };
var dto = new PersonDto(person); // Uses generated constructor
LINQ projection support:
var query = dbContext.People.Select(PersonDto.Projection).ToList();
Advanced Scenarios
- Generate records, structs, or record structs
- Include/exclude fields and properties
- Custom mapping logic for derived or formatted values
- Seamless integration with LINQ and EF Core
See the Advanced Scenarios guide for more.
Facet.Extensions for LINQ/EF Core async
Install Facet.Extensions for one-line mapping helpers:
dotnet add package Facet.Extensionsusing Facet.Extensions;
// Single object
var dto = person.ToFacet<Person, PersonDto>();
// Lists
var dtos = people.SelectFacets<Person, PersonDto>();
// IQueryable deferred projection
var query = dbContext.People.SelectFacet<Person, PersonDto>();
// EF Core async
var dtos = await dbContext.People.ToFacetsAsync<Person, PersonDto>();
var single = await dbContext.People.FirstFacetAsync<Person, PersonDto>();
Facet — Define less, project more.
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 was computed. 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
- Facet.Extensions (>= 1.7.0)
- 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 |
---|---|---|
2.9.0 | 40 | 10/1/2025 |
2.8.2 | 35 | 10/1/2025 |
2.8.1 | 250 | 9/21/2025 |
2.8.0 | 614 | 9/17/2025 |
2.7.0 | 160 | 9/12/2025 |
2.6.2 | 212 | 9/12/2025 |
2.6.1 | 260 | 9/10/2025 |
2.6.0 | 165 | 9/9/2025 |
2.5.0 | 254 | 9/4/2025 |
2.4.8 | 182 | 9/3/2025 |
2.4.7 | 335 | 9/1/2025 |
2.4.6 | 152 | 9/1/2025 |
2.4.5 | 206 | 8/30/2025 |
2.4.4 | 251 | 8/27/2025 |
2.4.3 | 191 | 8/27/2025 |
2.4.2 | 193 | 8/27/2025 |
2.4.0 | 207 | 8/26/2025 |
2.3.0 | 806 | 8/20/2025 |
2.2.0 | 146 | 8/20/2025 |
2.1.0 | 192 | 8/18/2025 |
2.0.1 | 392 | 8/5/2025 |
2.0.0 | 187 | 8/4/2025 |
1.9.3 | 141 | 7/4/2025 |
1.9.1 | 173 | 7/3/2025 |
1.9.0 | 177 | 7/3/2025 |
1.8.0 | 190 | 6/4/2025 |
1.7.0 | 350 | 6/3/2025 |