{"record":{"id":"71c48189407ff5ff","repo":"dotnet/efcore","slug":"creating-a-container-with-full-text-search-or-vect","errorCode":null,"errorMessage":"Creating a container with full-text search or vector properties inside a collection navigation is currently not supported using EF Core; path: '{path}'. Create the container using other means (e.g. Microsoft.Azure.Cosmos SDK).","messagePattern":"Creating a container with full-text search or vector properties inside a collection navigation is currently not supported using EF Core; path: '(.+?)'\\. Create the container using other means \\(e\\.g\\. Microsoft\\.Azure\\.Cosmos SDK\\)\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs","lineNumber":422,"sourceCode":"                var complexProperty = complexType.ComplexProperty;\n                AppendTypePathFromRoot(builder, complexProperty.DeclaringType);\n                AppendComplexPropertySegment(builder, complexProperty);\n                break;\n            }\n            case IReadOnlyEntityType entityType when entityType.IsOwned():\n            {\n                var ownership = entityType.FindOwnership()!;\n                var containingPropertyName = ownership.GetNavigation(pointsToPrincipal: false)!\n                        .TargetEntityType.GetContainingPropertyName()\n                    ?? throw new UnreachableException(\"Containing property name should not be null for owned entity types.\");\n\n                AppendTypePathFromRoot(builder, ownership.PrincipalEntityType);\n                builder.Append('/');\n                AppendEscapedPathSegment(builder, containingPropertyName);\n\n                if (!ownership.IsUnique)\n                {\n                    throw new NotSupportedException(\n                        CosmosStrings.CreatingContainerWithFullTextOrVectorOnCollectionNotSupported(builder.ToString()));\n                }\n\n                break;\n            }\n        }\n    }\n\n    private static void AppendComplexPropertySegment(StringBuilder builder, IReadOnlyComplexProperty complexProperty)\n    {\n        builder.Append('/');\n        AppendEscapedPathSegment(builder, complexProperty.GetJsonPropertyName());\n        if (complexProperty.IsCollection)\n        {\n            builder.Append(\"/[]\");\n        }\n    }\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs#L404-L440","documentation":"Thrown when EF Core's Cosmos provider tries to create a container and discovers a full-text search or vector index path that lives inside an owned collection navigation (a non-unique ownership). Cosmos full-text/vector policies require a fixed JSON path, but an owned collection emits an array ('/[]'), so the path is not stable. EF refuses to emit the container policy in that case and asks you to create the container out-of-band.","triggerScenarios":"Calling EnsureCreatedAsync/EnsureDeletedAsync (or any path that invokes CosmosClientWrapper container creation) for a model where an owned entity type reached via a collection navigation (ownership.IsUnique == false) declares a full-text index (FullTextIndex) or vector index (VectorIndex). AppendTypePathFromRoot walks from root to the owned type, and the non-unique ownership check at CosmosClientWrapper.cs:420 throws.","commonSituations":"Configuring a vector embedding or full-text property on a child entity that is modeled as an owned collection (e.g. a collection of owned 'Tag' or 'Embedding' objects). Migrating a relational model to Cosmos where a owned-list child happens to carry a vector/full-text column.","solutions":["Move the full-text/vector property off the owned-collection entity onto the document-root entity (or an owned singleton), so the ownership is unique and the path is stable.","Create the container (with its full-text/vector indexing policy) yourself using the Microsoft.Azure.Cosmos SDK before calling EnsureCreatedAsync, so EF does not try to derive the policy.","Re-model the child as a separate entity type in its own container instead of an owned collection.","Remove the full-text/vector index configuration for that property if it is not strictly required."],"exampleFix":"// before\nmodelBuilder.Entity<Order>().OwnsMany(o => o.Items, i =>\n    i.Property(x => x.Embedding).HasVector(VectorDataType.Float32, 1536));\n\n// after - move the vector to the document root\nmodelBuilder.Entity<Order>().Property(o => o.Embedding).HasVector(VectorDataType.Float32, 1536);\nmodelBuilder.Entity<Order>().OwnsMany(o => o.Items);\n// or create the container via the Microsoft.Azure.Cosmos SDK instead of EnsureCreatedAsync.","handlingStrategy":"validation","validationCode":"// Before calling EnsureCreatedAsync, scan the model for the unsupported pattern\nvar incompatible = dbContext.Model.GetEntityTypes()\n    .Where(et => et.IsOwned()\n        && et.FindOwnership()?.IsUnique == false\n        && (et.GetDeclaredProperties().Any(p => p.IsFullText())\n            || et.GetDeclaredProperties().Any(p => p.IsVector())))\n    .ToList();\nif (incompatible.Count != 0)\n{\n    // create the container via Microsoft.Azure.Cosmos SDK instead of EnsureCreatedAsync\n}","typeGuard":null,"tryCatchPattern":"try { await dbContext.Database.EnsureCreatedAsync(ct); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"full-text search or vector\"))\n{\n    // fall back to creating the container with the Azure Cosmos SDK,\n    // then retry your data operations (do NOT retry EnsureCreatedAsync unchanged).\n}","preventionTips":["Keep full-text/vector indexes on document-root entities or owned singletons, never on owned collections.","Create Cosmos containers with indexing policies out-of-band via the SDK when policies are non-trivial.","Review your model's owned collections whenever you add HasFullTextIndex/HasVector."],"tags":["cosmos","vector-search","full-text","owned-collection","container-creation"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}