Trellis.EntityFrameworkCore.Generator 3.0.0-alpha.158

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

Trellis.EntityFrameworkCore.Generator

NuGet

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.EntityFrameworkCore package

How It Works

  1. Analyzes your code for partial properties of type Maybe<T>
  2. Generates a private nullable backing field and getter/setter at compile-time
  3. MaybeConvention in Trellis.EntityFrameworkCore discovers the backing field and maps it as optional in EF Core
  4. 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
There are no supported framework assets in this package.

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