Trellis.EntityFrameworkCore.Generator
3.0.0-alpha.158
dotnet add package Trellis.EntityFrameworkCore.Generator --version 3.0.0-alpha.158
NuGet\Install-Package Trellis.EntityFrameworkCore.Generator -Version 3.0.0-alpha.158
<PackageReference Include="Trellis.EntityFrameworkCore.Generator" Version="3.0.0-alpha.158" />
<PackageVersion Include="Trellis.EntityFrameworkCore.Generator" Version="3.0.0-alpha.158" />
<PackageReference Include="Trellis.EntityFrameworkCore.Generator" />
paket add Trellis.EntityFrameworkCore.Generator --version 3.0.0-alpha.158
#r "nuget: Trellis.EntityFrameworkCore.Generator, 3.0.0-alpha.158"
#:package Trellis.EntityFrameworkCore.Generator@3.0.0-alpha.158
#addin nuget:?package=Trellis.EntityFrameworkCore.Generator&version=3.0.0-alpha.158&prerelease
#tool nuget:?package=Trellis.EntityFrameworkCore.Generator&version=3.0.0-alpha.158&prerelease
Trellis.EntityFrameworkCore.Generator
Roslyn source generator for Maybe<T> partial properties in EF Core entity types. Automatically generates private nullable backing fields and property implementations.
What It Does
Automatically generates backing field code for partial properties of type Maybe<T>:
// You write this:
public partial class Customer
{
public partial Maybe<PhoneNumber> Phone { get; set; }
public partial Maybe<DateTime> SubmittedAt { get; set; }
}
// Generator creates:
// - Private nullable backing field (_phone, _submittedAt)
// - Property getter: returns Maybe.From(_phone) or Maybe<T>.None
// - Property setter: extracts value or sets null
Installation
This package is included automatically when you install Trellis.EntityFrameworkCore:
dotnet add package Trellis.EntityFrameworkCore
Note: Both packages are required — the main package provides MaybeConvention and EF Core integration, this generator creates the property implementations.
Generated Code
For each partial Maybe<T> property, the generator emits:
// Auto-generated for: public partial Maybe<PhoneNumber> Phone { get; set; }
private PhoneNumber? _phone;
public partial Maybe<PhoneNumber> Phone
{
get => _phone is not null ? Maybe.From(_phone) : Maybe<PhoneNumber>.None;
set => _phone = value.HasValue ? value.Value : null;
}
Naming Convention
| Property | Backing Field | Column Name |
|---|---|---|
Phone |
_phone |
Phone |
SubmittedAt |
_submittedAt |
SubmittedAt |
AlternateEmail |
_alternateEmail |
AlternateEmail |
Diagnostics
| ID | Severity | Description |
|---|---|---|
| TRLSGEN100 | Warning | Maybe<T> property should be declared partial |
Requirements
- .NET Standard 2.0 compatible (source generators must target netstandard2.0)
- C# 13+ for partial property support
- Requires
Trellis.EntityFrameworkCorepackage
How It Works
- Analyzes your code for partial properties of type
Maybe<T> - Generates a private nullable backing field and getter/setter at compile-time
MaybeConventionin Trellis.EntityFrameworkCore discovers the backing field and maps it as optional in EF Core- No runtime reflection — all compile-time
Source Code
This is a source generator — it runs at compile-time and generates C# code. The generated code is visible in:
- Visual Studio: Dependencies → Analyzers → Trellis.EntityFrameworkCore.Generator
- Rider: Generated Sources
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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 |
|---|---|---|
| 3.0.0-alpha.158 | 49 | 4/5/2026 |
| 3.0.0-alpha.157 | 41 | 4/4/2026 |
| 3.0.0-alpha.140 | 54 | 3/30/2026 |
| 3.0.0-alpha.137 | 61 | 3/27/2026 |
| 3.0.0-alpha.135 | 40 | 3/26/2026 |
| 3.0.0-alpha.127 | 47 | 3/23/2026 |
| 3.0.0-alpha.123 | 46 | 3/19/2026 |
| 3.0.0-alpha.118 | 53 | 3/14/2026 |
| 3.0.0-alpha.111 | 50 | 3/12/2026 |
| 3.0.0-alpha.104 | 42 | 3/9/2026 |