dotnet/efcore · error · NotSupportedException
Creating a container with full-text search or vector propert
Error message
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). What it means
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.
Source
Thrown at src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs:422
var complexProperty = complexType.ComplexProperty;
AppendTypePathFromRoot(builder, complexProperty.DeclaringType);
AppendComplexPropertySegment(builder, complexProperty);
break;
}
case IReadOnlyEntityType entityType when entityType.IsOwned():
{
var ownership = entityType.FindOwnership()!;
var containingPropertyName = ownership.GetNavigation(pointsToPrincipal: false)!
.TargetEntityType.GetContainingPropertyName()
?? throw new UnreachableException("Containing property name should not be null for owned entity types.");
AppendTypePathFromRoot(builder, ownership.PrincipalEntityType);
builder.Append('/');
AppendEscapedPathSegment(builder, containingPropertyName);
if (!ownership.IsUnique)
{
throw new NotSupportedException(
CosmosStrings.CreatingContainerWithFullTextOrVectorOnCollectionNotSupported(builder.ToString()));
}
break;
}
}
}
private static void AppendComplexPropertySegment(StringBuilder builder, IReadOnlyComplexProperty complexProperty)
{
builder.Append('/');
AppendEscapedPathSegment(builder, complexProperty.GetJsonPropertyName());
if (complexProperty.IsCollection)
{
builder.Append("/[]");
}
}
View on GitHub (pinned to dbf9771522)
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.
Example fix
// before
modelBuilder.Entity<Order>()
.OwnsMany(o => o.Items, ib =>
{
ib.Property(i => i.Embedding).IsVectorProperty(DistanceFunction.Cosine, 128);
});
// after — make Item a root entity in its own container
modelBuilder.Entity<Order>().OwnsMany(o => o.Items, ib => { /* no vector config */ });
modelBuilder.Entity<OrderItem>()
.Property(i => i.Embedding)
.IsVectorProperty(DistanceFunction.Cosine, 128);
// or create the container via the Cosmos SDK directly Defensive patterns
Strategy: validation
Validate before calling
// Validate that no owned collection element has vector or full-text properties.
foreach (var entityType in model.GetEntityTypes())
{
var ownership = entityType.FindOwnership();
if (ownership is not null && !ownership.IsUnique) // owned collection
{
foreach (var property in entityType.GetProperties())
{
if (property.FindTypeMapping() is CosmosVectorTypeMapping
|| property.GetIsFullTextSearchEnabled() == true)
throw new InvalidOperationException($"Owned collection element {entityType.DisplayName()} has vector/full-text property {property.Name}.");
}
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- A vector index on '{entityType}' is defined over properties
- A full-text index on '{entityType}' is defined over multiple
- The requested configuration is not stored in the read-optimi
- The value '{value}' provided for argument '{argumentName}' m
- Ordering based on scoring function is not supported inside '
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/71c48189407ff5ff.
Report an issue: GitHub.