Stackworx.EfCoreGraphQL.DesignTime 0.0.3-alpha

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

Stackworx.EfCoreGraphQL.DesignTime

Generates HotChocolate DataLoaders and field extensions from your EF Core model whenever dotnet ef scaffolds a migration, by registering a custom IMigrationsCodeGenerator. Output is written next to the model snapshot as {ModelSnapshotName}.DataLoaders.g.cs.

1) Reference the package

Reference it from the project EF tooling loads design-time services from (commonly your startup project).

2) Register the generator

EF Core tooling discovers IDesignTimeServices automatically:

using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.DependencyInjection;
using Stackworx.EfCoreGraphQL.DesignTime;

public sealed class DesignTimeServices : IDesignTimeServices
{
    public void ConfigureDesignTimeServices(IServiceCollection services)
        => services.AddEfCoreGraphQL();
}

3) Configure generation

AddEfCoreGraphQL takes a GenerateOptions, or an Action<GenerateOptions>:

using Stackworx.EfCoreGraphQL;
using Stackworx.EfCoreGraphQL.Abstractions;

public void ConfigureDesignTimeServices(IServiceCollection services)
    => services.AddEfCoreGraphQL(options =>
    {
        // Generate only for entities marked [EFCoreGraphQLInclude].
        options.Mode = Mode.OptIn;

        // Identity types are declared by the framework, so they cannot be annotated.
        options.Filter = EntityTypeFilters.AspNetIdentity;

        // Keep foreign-key scalars in an existing schema; clients may already select them.
        options.IgnoreForeignKeyFields = false;
    });
Option Default Effect
Mode Mode.OptOut OptOut generates for every entity except those marked [EFCoreGraphQLIgnore]; OptIn only for [EFCoreGraphQLInclude].
Filter none Func<IEntityType, bool>; return true to exclude an entity. For types you cannot annotate.
Namespace derived Defaults to {modelSnapshotNamespace}.Generated.DataLoaders. Set it to choose your own.
IgnoreForeignKeyFields true Hides foreign-key scalar fields via ExtendObjectType(IgnoreFields = ...) because the navigation replaces them.
CI false Runtime-only (DataLoaderGenerator.Generate); ignored during scaffolding, where the model is expected to change.

Registering the generator directly — services.AddSingleton<IMigrationsCodeGenerator, EfCoreMigrationsCodeGenerator>() — still works and uses the defaults above.

Adopting into an existing schema

Mode.OptIn with IgnoreForeignKeyFields = false adds nothing to the schema until you mark a type, and does not remove fields clients already select:

options.Mode = Mode.OptIn;
options.IgnoreForeignKeyFields = false;
[EFCoreGraphQLInclude]
public class Author { /* ... */ }

4) Set the output directory (required)

During scaffolding EF Core's working directory is often not the migrations project, so the output directory has to be explicit:

export STACKWORX_EFCOREGRAPHQL_SIDECAR_OUTPUT_DIR="/absolute/path/to/YourProject/Migrations"
$env:STACKWORX_EFCOREGRAPHQL_SIDECAR_OUTPUT_DIR = "C:\path\to\YourProject\Migrations"

It must point to an existing directory. Scaffolding fails with a clear error when it is unset or wrong.

5) Scaffold

dotnet ef migrations add InitialCreate \
  --project ./src/Your.Migrations.Project \
  --startup-project ./src/Your.Api.Project

The sidecar is rewritten on every snapshot generation, so changes that don't affect the snapshot text (e.g. adding [EFCoreGraphQLIgnore]) still take effect.

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
0.0.3-alpha 43 8/3/2026
0.0.2-alpha 125 2/21/2026
0.0.1-alpha 65 2/21/2026