{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs#L404-L440","documentation":"EF Core cannot create a Cosmos container that includes full-text search or vector embedding policies inside a non-unique owned navigation (a collection of owned entities). The Cosmos SDK requires vector/full-text policy paths to be deterministic, and collection-owned entities map to array paths (/Collection/[]), which the policy does not support for these feature types. The check is at CosmosClientWrapper.cs:420-424 during path building.","triggerScenarios":"Using OwnsMany with an owned entity that has a vector property (IsVectorProperty) or a full-text property (IsFullTextSearch), then calling EnsureCreatedAsync/EnsureCreated to create the container. The path builder hits the non-unique ownership and throws NotSupportedException.","commonSituations":"Modeling an owned collection (e.g., Order.OwnsMany(o => o.Tags)) where each tag has an embedding for similarity search. Embedding search over items in a collection navigation. Full-text search inside a nested collection.","solutions":["Move the vector/full-text property to a document-root entity type instead of an owned collection element. Model the collection as a separate entity with its own container or as a root document.","Create the container manually using the Microsoft.Azure.Cosmos SDK directly, bypassing EF Core's EnsureCreated, if your schema genuinely requires this structure.","Restructure so the owned relationship is unique (OwnsOne) rather than a collection, if semantically appropriate."],"exampleFix":"// before\nmodelBuilder.Entity<Order>()\n    .OwnsMany(o => o.Items, ib =>\n    {\n        ib.Property(i => i.Embedding).IsVectorProperty(DistanceFunction.Cosine, 128);\n    });\n\n// after — make Item a root entity in its own container\nmodelBuilder.Entity<Order>().OwnsMany(o => o.Items, ib => { /* no vector config */ });\nmodelBuilder.Entity<OrderItem>()\n    .Property(i => i.Embedding)\n    .IsVectorProperty(DistanceFunction.Cosine, 128);\n// or create the container via the Cosmos SDK directly","handlingStrategy":"validation","validationCode":"// Validate that no owned collection element has vector or full-text properties.\nforeach (var entityType in model.GetEntityTypes())\n{\n    var ownership = entityType.FindOwnership();\n    if (ownership is not null && !ownership.IsUnique) // owned collection\n    {\n        foreach (var property in entityType.GetProperties())\n        {\n            if (property.FindTypeMapping() is CosmosVectorTypeMapping\n                || property.GetIsFullTextSearchEnabled() == true)\n                throw new InvalidOperationException($\"Owned collection element {entityType.DisplayName()} has vector/full-text property {property.Name}.\");\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not put vector or full-text properties inside OwnsMany configurations.","Model search-targeted data as document-root entities.","If the nested-collection structure is mandatory, create containers via the Cosmos SDK, not EnsureCreated."],"tags":["cosmos","owned-entities","vector-search","full-text-search","container-creation"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}