-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Obsolete owned JSON entities in relational #37363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bf84826 to
09e8e38
Compare
09e8e38 to
e9e6c8a
Compare
src/EFCore.Relational/Extensions/RelationalOwnedNavigationBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
AndriySvyryd
left a comment
There was a problem hiding this 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
There was a problem hiding this 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 toToJson()extension methods with diagnostic ID EF8001 - Introduced diagnostic constants in
EFDiagnostics.csfor 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 |
2446e51 to
5c4afe4
Compare
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. |
Closes #37290