Repository navigation
Add support for JSON, composite, include and exclude Cosmos indexes - #38360
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the EF Core Cosmos provider to support richer indexing scenarios (including indexes through complex types/complex collections, composite indexes, and container-level automatic indexing include/exclude behavior), and updates validation and tests accordingly.
Changes:
- Add Cosmos container automatic-indexing configuration (
HasAutomaticIndexing(...)+Except(...)) and flow these settings into container creation. - Generate Cosmos indexing-policy paths for scalar properties nested in complex types and complex collections (including escaping/quoting as needed), and emit composite/vector/full-text index policy entries.
- Update Cosmos model validation and expand functional/unit test coverage (including compiled-model baselines) for the new indexing behavior.
Reviewed changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/EFCore.Cosmos.Tests/Storage/Internal/CosmosClientWrapperTest.cs | Adds unit coverage for JSON path generation/escaping for scalar, complex, and complex-collection segments. |
| test/EFCore.Cosmos.Tests/Metadata/CosmosEntityTypeExtensionsTest.cs | Adds unit coverage for the new automatic-indexing builder behavior and convention APIs. |
| test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs | Updates/expands validator tests for composite, vector, full-text, include/exclude, and container consistency scenarios. |
| test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs | Plumbs automatic-indexing enabled/exceptions into test container creation. |
| test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs | Adds compiled-model test for index types and ensures design-time-only annotations are stripped. |
| test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Cosmos_model_with_index_types/IndexedDataUnsafeAccessors.cs | New compiled-model baseline output for the added indexing test model. |
| test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Cosmos_model_with_index_types/IndexedDataEntityType.cs | New compiled-model baseline output representing entity/index metadata. |
| test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Cosmos_model_with_index_types/DbContextModelBuilder.cs | New compiled-model baseline output for runtime model builder. |
| test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Cosmos_model_with_index_types/DbContextModel.cs | New compiled-model baseline output for runtime model initialization. |
| test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Cosmos_model_with_index_types/DbContextAssemblyAttributes.cs | New compiled-model baseline assembly attribute for Cosmos runtime model. |
| test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs | Adds a roundtrip test for vector index configuration through a complex collection. |
| test/EFCore.Cosmos.FunctionalTests/Query/Translations/FullTextSearchTranslationsCosmosTest.cs | Adds a roundtrip test for full-text index configuration through a complex collection. |
| test/EFCore.Cosmos.FunctionalTests/Query/Associations/ComplexProperties/ComplexPropertiesProjectionCosmosTest.cs | Adds TODO markers for known “select entire document” behavior (tracking an existing issue). |
| test/EFCore.Cosmos.FunctionalTests/Query/AdHocComplexTypeQueryCosmosTest.cs | Updates complex-type tests to reflect newly-supported index scenarios and adds discriminator-in-id coverage. |
| test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs | Updates expectations for owned-type index traversal (now rejected with a more specific message). |
| test/EFCore.Cosmos.FunctionalTests/CosmosSessionTokensTest.cs | Stabilizes session token assertions by separating create vs delete phases. |
| test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs | Registers the new fluent API builder type for API consistency checks. |
| src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs | Flows automatic indexing enabled/exceptions from model into container-creation parameters. |
| src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs | Implements indexing-policy emission (included/excluded paths, composite indexes) and robust JSON path building from root (incl. complex/collection segments). |
| src/EFCore.Cosmos/Storage/Internal/ContainerProperties.cs | Extends container-creation parameter record with automatic-indexing enabled/exceptions. |
| src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs | Ensures property reads navigate into complex JSON objects when a scalar property is declared on a complex type. |
| src/EFCore.Cosmos/Properties/CosmosStrings.resx | Adds/updates Cosmos provider error messages for automatic-indexing consistency and owned-type index traversal. |
| src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs | Updates generated string accessors/summaries to match new/changed resources. |
| src/EFCore.Cosmos/Metadata/Internal/CosmosAnnotationNames.cs | Adds new annotation names for automatic-indexing enabled/exceptions. |
| src/EFCore.Cosmos/Metadata/Conventions/CosmosRuntimeModelConvention.cs | Strips automatic-indexing annotations from runtime model (design-time-only). |
| src/EFCore.Cosmos/Metadata/Builders/CosmosAutomaticIndexingBuilder.cs | Introduces fluent builder enabling Except(...) chaining for indexing-policy excluded paths. |
| src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs | Adds container-level validation for automatic-indexing settings and rejects regular indexes declared on owned types. |
| src/EFCore.Cosmos/Extensions/CosmosIndexExtensions.cs | Fixes convention annotation setter return type for full-text index flag. |
| src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs | Adds extensions for getting/setting automatic-indexing enabled/exceptions (incl. convention APIs). |
| src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs | Adds HasAutomaticIndexing(...) fluent API and convention builder helpers. |
| src/EFCore.Cosmos/Extensions/CosmosComplexCollectionTypePropertyBuilderExtensions.cs | Enables full-text/vector configuration APIs for properties inside complex collections. |
| src/EFCore.Cosmos/EFCore.Cosmos.baseline.json | Updates API baseline for new public surface (automatic-indexing builder + new extension methods). |
| src/EFCore.Cosmos/Design/Internal/CosmosCSharpRuntimeAnnotationCodeGenerator.cs | Ensures automatic-indexing annotations aren’t emitted into the runtime model during design-time code generation. |
Files not reviewed (1)
- src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs: Language not supported
3 tasks done
AndriySvyryd
commented
Jun 5, 2026
cincuranet
approved these changes
Jun 9, 2026
AndriySvyryd
enabled auto-merge (squash)
June 9, 2026 22:46
Contributor
API review baseline changes for
|
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.
Add support for chaining into complex collections in indexes
Add support for keys spanning non-collection complex properties
Fixes #38067
Fixes #17303