Skip to content

Declare DbSet properties as auto-properties without initializers - #10697

Merged
glen-84 merged 1 commit into
mainfrom
gai/use-dbset-auto-properties
Oct 26, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/use-dbset-auto-properties

Conversation

@glen-84

@glen-84 glen-84 commented Oct 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Declares every DbSet property in the tests, the examples, the k6 benchmark app, and the Mocha docs as public DbSet<T> Name { get; set; }, the form EF Core documents and scaffolds.
  • Removes the = null! initializers from 47 properties. The DbContext constructor assigns settable DbSet properties, and EF Core 7.0+ ships a diagnostic suppressor that silences CS8618 on them.
  • Replaces the 56 expression-bodied => Set<T>() properties (5 of them in the Mocha docs) with the same auto-property form, so the repo uses one declaration style.

Test plan

  • Built all 18 affected projects for every target framework with no warnings. Nullable warnings are errors in this repo, so an unsuppressed CS8618 would fail the build.
  • Ran Data.EntityFramework.Tests, Data.PostgreSQL.Tests, GreenDonut.Data.EntityFramework.Tests, Mocha.EntityFrameworkCore.Tests, and Mocha.EntityFrameworkCore.Postgres.Tests on net10.0: all pass.
  • Prettier check on the two Mocha docs pages.

Copilot AI lite review requested due to automatic review settings October 26, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review comments were identified, and all supplied approval assessments indicate readiness for approval.

No open issues 🎉

What changed in this PR

This pull request standardizes Entity Framework Core DbSet<T> declarations across tests, examples, benchmarks, and Mocha documentation using settable auto-properties without redundant null! initializers or expression-bodied Set<T>() accessors.

Changes:

  • Replaces expression-bodied DbSet<T> properties with { get; set; } auto-properties.
  • Removes redundant = null! initializers.
  • Updates Mocha examples and documentation to use the same EF Core declaration style.
File Description
website/​content/​docs/​mocha/​sagas.md Updates the saga DbSet documentation example.
website/​content/​docs/​mocha/​reliability.md Updates outbox and inbox DbSet documentation examples.
src/​Mocha/​test/​Mocha.EntityFrameworkCore.Tests/​EntityFrameworkTransactionMiddlewareTests.cs Standardizes the test context property.
src/​Mocha/​test/​Mocha.EntityFrameworkCore.Postgres.Tests/​PostgresOutboxConnectionLifetimeTests.cs Standardizes the PostgreSQL test context property.
src/​Mocha/​src/​Examples/​Reliability/​OutboxInbox/​OutboxInbox.cs Updates the outbox, inbox, and order set declarations.
src/​Mocha/​examples/​Demo/​Demo.Shipping/​Data/​ShippingDbContext.cs Updates shipping demo set declarations.
src/​Mocha/​examples/​Demo/​Demo.Catalog/​Data/​CatalogDbContext.cs Updates catalog demo set declarations.
src/​Mocha/​examples/​Demo/​Demo.Billing/​Data/​BillingDbContext.cs Updates billing demo set declarations.
src/​HotChocolate/​Spatial/​test/​Data.Projections.SqlServer.Tests/​DatabaseContext.cs Removes the generic set initializer.
src/​HotChocolate/​Spatial/​test/​Data.Filters.SqlServer.Tests/​DatabaseContext.cs Removes the generic set initializer.
src/​HotChocolate/​Data/​test/​Data.Tests/​TestContext2/​FooBarContext.cs Removes null! initializers.
src/​HotChocolate/​Data/​test/​Data.Tests/​TestContext2/​CatalogContext.cs Removes null! initializers.
src/​HotChocolate/​Data/​test/​Data.Tests/​TestContext2/​AnimalContext.cs Removes null! initializers.
src/​HotChocolate/​Data/​test/​Data.Tests/​TestContext1/​CatalogContext.cs Removes null! initializers.
src/​HotChocolate/​Data/​test/​Data.Sorting.SqlLite.Tests/​QueryableSortVisitorProjectionTests.cs Removes the test set initializer.
src/​HotChocolate/​Data/​test/​Data.Sorting.SqlLite.Tests/​DatabaseContext.cs Removes the generic set initializer.
src/​HotChocolate/​Data/​test/​Data.Projections.SqlServer.Tests/​DatabaseContext.cs Removes the generic set initializer.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​Issue8252UnionProjectionTests.cs Standardizes the projection context property.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​DateTimeOffsetSortingTests.cs Removes the test set initializer.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​Data/​CatalogContext.cs Standardizes catalog set declarations.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​ComputedExpressionProjectionTests.cs Standardizes the expression projection context property.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​AsSelectorRecordProjectionTests.cs Standardizes the record projection context property.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​AsSelectorEncapsulatedProjectionTests.cs Standardizes encapsulated projection set declarations.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​ArrayLengthProjectionTests.cs Standardizes the projection context property.
src/​HotChocolate/​Data/​test/​Data.PostgreSQL.Tests/​ArrayLengthFilterTests.cs Standardizes the filter context property.
src/​HotChocolate/​Data/​test/​Data.NodaTime.Tests/​TestContext/​BookContext.cs Removes null! initializers.
src/​HotChocolate/​Data/​test/​Data.Filters.SqlServer.Tests/​TestContext/​CatalogContext.cs Removes null! initializers.
src/​HotChocolate/​Data/​test/​Data.Filters.SqlServer.Tests/​DatabaseContext.cs Removes the generic set initializer.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​QueryContextProjectionTests.cs Standardizes projection context set declarations.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​Issue8407ProbeTests.cs Standardizes probe context set declarations.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​Issue8252ProbeTests.cs Standardizes the probe context property.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​Issue5449Tests.cs Standardizes the test context property.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​IsProjectedSelectorTests.cs Standardizes the selector context property.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​InterfaceFieldProjectionTests.cs Standardizes the projection context property.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​InterfaceFieldFilterAndSortTests.cs Removes the test set initializer.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​IntegrationTests.cs Standardizes integration-test context properties.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​DatabaseContext.cs Removes the generic set initializer.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Tests/​BookContext.cs Removes null! initializers.
src/​HotChocolate/​Data/​test/​Data.EntityFramework.Pagination.Tests/​TestContext/​CatalogContext.cs Removes null! initializers.
src/​HotChocolate/​AspNetCore/​benchmarks/​k6/​Catalog.API/​Data/​CatalogContext.cs Updates benchmark context set declarations.
src/​GreenDonut/​test/​GreenDonut.Data.EntityFramework.Tests/​TestContext/​NullableTestsContext.cs Removes null! initializers.
src/​GreenDonut/​test/​GreenDonut.Data.EntityFramework.Tests/​TestContext/​FooBarContext.cs Removes null! initializers.
src/​GreenDonut/​test/​GreenDonut.Data.EntityFramework.Tests/​TestContext/​FileSystemContext.cs Standardizes file-system context set declarations.
src/​GreenDonut/​test/​GreenDonut.Data.EntityFramework.Tests/​TestContext/​CatalogContext.cs Removes null! initializers.
src/​GreenDonut/​test/​GreenDonut.Data.EntityFramework.Tests/​TestContext/​AnimalContext.cs Removes null! initializers.
src/​GreenDonut/​test/​GreenDonut.Data.EntityFramework.Tests/​RelativeCursorTests.cs Standardizes the cursor test context property.
src/​GreenDonut/​test/​GreenDonut.Data.EntityFramework.Tests/​PagingTotalCountTests.cs Standardizes the paging test context property.

Review effort: Lite

@glen-84
glen-84 merged commit 7080b54 into main Oct 26, 2026
158 checks passed
@glen-84
glen-84 deleted the gai/use-dbset-auto-properties branch October 26, 2026 12:26
This was referenced Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants