Repository navigation
Leave out a DbContext's own members by type, not by name on every type - #566
Open
lukemurray wants to merge 1 commit into
Open
lukemurray wants to merge 1 commit into
lukemurray wants to merge 1 commit into
Conversation
IgnoreProps held Database, Model, ChangeTracker and ContextId by default, to keep an EF Core DbContext's machinery out of the schema. It matches by name on every type, so any entity property called Model (or Database, ...) was silently dropped from the schema too. Members declared on Microsoft.EntityFrameworkCore.DbContext are now left out by their declaring type, matched by name so there is still no EF reference, and IgnoreProps is empty by default. It still ignores whatever names are added to it, everywhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukemurray
force-pushed
the
fix/ignore-props-only-on-dbcontext
branch
from
October 9, 2026 22:07
e78a7ba to
7300671
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SchemaBuilderOptions.IgnorePropsdefaulted to["Database", "Model", "ChangeTracker", "ContextId"]to keep an EF CoreDbContext's own members out of the schema. ButShouldIncludeMemberchecks it by name on every type. So an entity property calledModel(a car's model, the model a request ran on) silently disappeared from the schema, with nothing to say why. The same went forDatabase,ChangeTrackerandContextId.Change
DbContext's members are left out by where they are declared. Any member declared onMicrosoft.EntityFrameworkCore.DbContextis skipped. The match is on the type's full name, so EntityGraphQL still needs no reference to EF.IgnorePropsis now empty by default. It still ignores any name added to it, on every type, as documented.Behaviour change
A schema whose types have a property named
Model,Database,ChangeTrackerorContextIdnow includes that field. To keep it out:options.Builder.IgnoreProps.Add("Model"), or[GraphQLIgnore]on the property.Logged under a new 6.3.0 heading in the changelog; relabel if you'd rather.
Tests
DbContextschema has no rootdatabase,model,changeTrackerorcontextIdfield. This fails without the declaring-type check.ModelandDatabaseproperties are fields. This fails with the old default list.IgnorePropsstill ignores a name that's added to it.Both suites pass on net10.0 (core 1208, EF 48).
Side note
.config/dotnet-tools.jsonlists the command asdotnet-csharpier, but CSharpier 1.0 renamed it tocsharpier, sodotnet tool restorefails. That's not changed here. I formatted withdnx csharpier@1.0.0and only kept formatting on the lines this PR changes.🤖 Generated with Claude Code