dotnet/efcore · error · InvalidOperationException
Property '{entityType}.{property}' was configured for full-t
Error message
Property '{entityType}.{property}' was configured for full-text search, but has type '{clrType}'; only string properties can be configured for full-text search. What it means
Cosmos DB full-text search can only be applied to string properties. During container creation (CosmosClientWrapper.cs:248-255), EF Core iterates all properties marked with GetIsFullTextSearchEnabled() and throws if property.ClrType is not typeof(string). Non-string types (int, byte[], DateTime, etc.) are incompatible with the Cosmos full-text policy.
Source
Thrown at src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs:250
? CompositePathSortOrder.Descending
: CompositePathSortOrder.Ascending;
compositePaths.Add(new CompositePath { Path = path, Order = order });
key.Append(path).Append('=').Append(order).Append('|');
}
if (seenCompositeIndexes.Add(key.ToString()))
{
compositeIndexes.Add(compositePaths);
}
}
}
var fullTextPaths = new Collection<FullTextPath>();
foreach (var (property, language) in parameters.FullTextProperties)
{
if (property.ClrType != typeof(string))
{
throw new InvalidOperationException(
CosmosStrings.FullTextSearchConfiguredForUnsupportedPropertyType(
property.DeclaringType.DisplayName(),
property.Name,
property.ClrType.Name));
}
fullTextPaths.Add(
new FullTextPath
{
Path = GetJsonPropertyPathFromRoot(property),
// TODO: remove the fallback once Cosmos SDK allows optional language (see #35939)
Language = language ?? parameters.DefaultFullTextLanguage ?? "en-US"
});
}
var embeddings = new Collection<Embedding>();
foreach (var (property, vectorType) in parameters.Vectors)
{View on GitHub (pinned to dbf9771522)
Solutions
- Only configure full-text search on string properties. Remove .IsFullTextSearch() from non-string properties.
- If you need to search non-text data, store a string representation in a separate property and full-text index that.
- Recreate the container after fixing the model.
Example fix
// before
modelBuilder.Entity<Document>()
.Property(d => d.FileSize) // int
.IsFullTextSearch();
// after
modelBuilder.Entity<Document>()
.Property(d => d.Content) // string
.IsFullTextSearch(); Defensive patterns
Strategy: validation
Validate before calling
// Validate that every full-text-search-enabled property is a string.
foreach (var entityType in model.GetEntityTypes())
{
foreach (var property in entityType.GetProperties())
{
if (property.GetIsFullTextSearchEnabled() == true && property.ClrType != typeof(string))
throw new InvalidOperationException($"{property.Name} is full-text but not a string.");
}
} Type guard
// Guard: only enable full-text search on string properties
static void ConfigureFullText<T>(EntityTypeBuilder<T> eb, Expression<Func<T, string>> prop)
where T : class
=> eb.HasIndex(prop).ForCosmos().IsFullTextIndex(); Prevention
- Only call IsFullTextSearch() on string-typed properties.
- Review model conventions that blanket-enable full-text search.
- Add a model-validation test that full-text properties have ClrType == string.
When it happens
Trigger: Calling .IsFullTextSearch() (or configuring full-text search via the property API) on a non-string property, e.g. an int Id, a byte[] blob, or a DateTime. This fires at container-creation time when the full-text policy paths are built.
Common situations: Enabling full-text search on all indexed properties without checking their types. Applying a blanket convention that marks properties as full-text searchable. Migrating a schema where a numeric or binary field was previously searched.
Related errors
- The type '{givenType}' cannot be mapped as a dictionary beca
- The partition key value supplied for '{propertyType}' proper
- Ordering based on scoring function is not supported inside '
- Only one ordering using scoring function is allowed. Use 'EF
- Ordering using a scoring function is mutually exclusive with
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/d4f50b014f9f6353.
Report an issue: GitHub.