{"record":{"id":"96f7491aa4a92a05","repo":"dotnet/efcore","slug":"a-vector-index-on-entitytype-is-defined-over-p-96f749","errorCode":null,"errorMessage":"A vector index on '{entityType}' is defined over properties `{properties}`. A vector index can only target a single property.","messagePattern":"A vector index on '(.+?)' is defined over properties `(.+?)`\\. A vector index can only target a single property\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs","lineNumber":185,"sourceCode":"    {\n        var (parameters, wrapper) = parametersTuple;\n        var partitionKeyPaths = parameters.PartitionKeyStoreNames.Select(e => \"/\" + e).ToList();\n\n        var vectorIndexes = new Collection<VectorIndexPath>();\n        var fullTextIndexPaths = new Collection<FullTextIndexPath>();\n        var includedPaths = new Collection<IncludedPath>();\n        var conventionIncludedPaths = new Collection<IncludedPath>();\n        var compositeIndexes = new Collection<Collection<CompositePath>>();\n        var seenIncludedPaths = new HashSet<string>();\n        var seenCompositeIndexes = new HashSet<string>();\n        foreach (var index in parameters.Indexes)\n        {\n            var vectorIndexType = index.GetVectorIndexType();\n            if (vectorIndexType != null)\n            {\n                if (index.Properties.Count > 1)\n                {\n                    throw new InvalidOperationException(\n                        CosmosStrings.CompositeVectorIndex(\n                            index.DeclaringEntityType.DisplayName(),\n                            string.Join(\",\", index.Properties.Select(e => e.Name))));\n                }\n\n                vectorIndexes.Add(\n                    new VectorIndexPath { Path = GetJsonPropertyPathFromRoot(index.Properties[0]), Type = vectorIndexType.Value });\n                continue;\n            }\n\n            if (index.IsFullTextIndex() == true)\n            {\n                if (index.Properties.Count > 1)\n                {\n                    throw new InvalidOperationException(\n                        CosmosStrings.CompositeFullTextIndex(\n                            index.DeclaringEntityType.DisplayName(),\n                            string.Join(\",\", index.Properties.Select(e => e.Name))));","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs#L167-L203","documentation":"CosmosClientWrapper throws CompositeVectorIndex when building container indexing policy and encounters a vector index whose index.Properties contains more than one property. Cosmos DB vector indexes must target exactly one path; composite vector indexes are not supported.","triggerScenarios":"Defining an index over multiple properties and marking it as a vector index, e.g. modelBuilder.Entity<T>().HasIndex(x => new { x.A, x.B }).IsVectorIndex(...).","commonSituations":"Bulk-applying the same index configuration to multi-property indexes; copy-pasting a composite index definition and adding IsVectorIndex.","solutions":["Define the vector index over exactly one property.","Define a separate single-property vector index for each vector property."],"exampleFix":"// before\nmodelBuilder.Entity<Item>()\n    .HasIndex(x => new { x.Embedding1, x.Embedding2 })\n    .IsVectorIndex(VectorIndexType.DiskANN);\n\n// after - one vector index per property\nmodelBuilder.Entity<Item>().HasIndex(x => x.Embedding1).IsVectorIndex(VectorIndexType.DiskANN);\nmodelBuilder.Entity<Item>().HasIndex(x => x.Embedding2).IsVectorIndex(VectorIndexType.DiskANN);","handlingStrategy":"validation","validationCode":"// At model build, assert vector indexes target exactly one property.\nforeach (var idx in entityType.GetIndexes())\n{\n    if (idx.GetVectorIndexType() is not null && idx.Properties.Count > 1)\n        throw new InvalidOperationException($\"Vector index on {entityType.DisplayName()} targets multiple properties.\");\n}","typeGuard":"static bool IsSinglePropertyVectorIndex(IIndex idx) => idx.GetVectorIndexType() is not null && idx.Properties.Count == 1;","tryCatchPattern":null,"preventionTips":["Define vector indexes over a single property only.","Add a model-build validator that rejects multi-property vector indexes.","Review all HasIndex(...).IsVectorIndex(...) calls during code review."],"tags":["cosmos","indexing","vector-search","model"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}