Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Dec 14, 2025

Closes #37290

@roji roji force-pushed the DeprecateOwnedJson branch from bf84826 to 09e8e38 Compare December 14, 2025 09:35
@roji roji force-pushed the DeprecateOwnedJson branch from 09e8e38 to e9e6c8a Compare December 14, 2025 17:14
@roji roji marked this pull request as ready for review December 15, 2025 09:35
@roji roji requested a review from a team as a code owner December 15, 2025 09:35
Copy link
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

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

File an issue to remove the obsoletion before RC2 so we don't forget

Copilot AI review requested due to automatic review settings December 27, 2025 22:11
@roji roji enabled auto-merge (squash) December 27, 2025 22:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request obsoletes the ToJson() method for owned JSON entities in EF Core's relational functionality, encouraging developers to migrate to complex types for JSON mapping instead. The change introduces a new diagnostic code (EF8001) and adds #pragma warning disable/restore directives throughout the test suite to suppress warnings for existing usage of the obsolete API.

Key Changes:

  • Added [Obsolete] attributes to ToJson() extension methods with diagnostic ID EF8001
  • Introduced diagnostic constants in EFDiagnostics.cs for the obsolete owned JSON entities feature
  • Suppressed EF8001 warnings across test files that continue to test the now-obsolete functionality

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Shared/EFDiagnostics.cs Added constants for EF8001 diagnostic and obsolete message for owned JSON entities
src/EFCore.Relational/Extensions/RelationalOwnedNavigationBuilderExtensions.cs Marked four ToJson() overloads as obsolete with diagnostic ID EF8001
test/EFCore.Specification.Tests/TestUtilities/BuildSource.cs Configured compiler to suppress EF8001 warnings in dynamically compiled test code
test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs Added pragma directives to suppress EF8001 warnings for owned entity type tests
test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.Json.cs Added file-level pragma to suppress warnings for JSON validation tests
test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs Wrapped owned-to-complex conversion test with pragma directives
test/EFCore.Relational.Tests/Metadata/Conventions/TableSharingConcurrencyTokenConventionTest.cs Added pragma directives around JSON-mapped entity test
test/EFCore.Relational.Specification.Tests/Update/JsonUpdateFixtureBase.cs Added file-level pragma to suppress warnings for JSON update test fixtures
test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalFixture.cs Added file-level pragma to suppress warnings for JSON query fixtures
test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalTestBase.cs Wrapped OnModelCreating method with pragma directives for JSON entity configuration
test/EFCore.Relational.Specification.Tests/Query/OptionalDependentQueryFixtureBase.cs Wrapped OnModelCreating method with pragma directives for JSON entity setup
test/EFCore.Relational.Specification.Tests/Query/OperatorsQueryTestBase.cs Added pragma directives around JSON scalar concatenation test
test/EFCore.Relational.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryRelationalTestBase.cs Wrapped column collection test with pragma directives
test/EFCore.Relational.Specification.Tests/Query/AdHocPrecompiledQueryRelationalTestBase.cs Added pragma directives around JsonContext class definition
test/EFCore.Relational.Specification.Tests/Query/AdHocJsonQueryRelationalTestBase.cs Added file-level pragma to suppress warnings for ad-hoc JSON query tests
test/EFCore.Relational.Specification.Tests/Query/Associations/OwnedJson/OwnedJsonRelationalFixtureBase.cs Added file-level pragma to suppress warnings in owned JSON association tests
test/EFCore.Relational.Specification.Tests/Scaffolding/CompiledModelRelationalTestBase.cs Added pragma directives around ToJson() calls in conditional blocks
test/EFCore.Relational.Specification.Tests/PropertyValuesRelationalTestBase.cs Added file-level pragma to suppress warnings for property values tests
test/EFCore.Relational.Specification.Tests/ModelBuilding/RelationalTestModelBuilderExtensions.cs Marked test helper ToJson() extension methods as obsolete with diagnostic ID
test/EFCore.Relational.Specification.Tests/Migrations/MigrationsTestBase.cs Added pragma directives around multiple JSON-related migration tests
test/EFCore.Relational.Specification.Tests/ComplexTypesTrackingRelationalTestBase.cs Wrapped OnModelCreating method with pragma directives for JSON entity configuration
test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs Renamed test method and added pragma directives for vector inside JSON owned entity test
test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs Added pragma directives around column type alteration tests for owned types
test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateJsonTypeSqlServerFixture.cs Added file-level pragma to suppress warnings for SQL Server JSON update tests
test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerFixture.cs Added file-level pragma to suppress warnings for SQL Server JSON query tests
test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs Wrapped OnModelCreating method with pragma directives for context setup
test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTestBase.cs Added file-level pragma to suppress warnings for SQL Server ad-hoc JSON tests
test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs Added pragma directives around multiple JSON entity tests with nested restore directive
test/EFCore.SqlServer.FunctionalTests/MaterializationInterceptionSqlServerTest.cs Wrapped OnModelCreating method with pragma directives for owned JSON entity setup
test/EFCore.Sqlite.FunctionalTests/MaterializationInterceptionSqliteTest.cs Wrapped OnModelCreating method with pragma directives for owned JSON entity configuration
test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs Added pragma directives around JSON snapshot storage tests

@roji roji force-pushed the DeprecateOwnedJson branch from 2446e51 to 5c4afe4 Compare December 28, 2025 08:46
@roji roji merged commit 97bd46a into dotnet:main Dec 28, 2025
7 checks passed
@roji roji deleted the DeprecateOwnedJson branch December 28, 2025 09:34
@roji
Copy link
Member Author

roji commented Dec 28, 2025

File an issue to remove the obsoletion before RC2 so we don't forget

I've reopened #37290 and it's still in the 11 milestone; we can use it both to gather feedback and to remember to revisit the question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider (not) deprecating relational owned JSON support

2 participants