{"record":{"id":"d4f50b014f9f6353","repo":"dotnet/efcore","slug":"property-entitytype-property-was-configured","errorCode":null,"errorMessage":"Property '{entityType}.{property}' was configured for full-text search, but has type '{clrType}'; only string properties can be configured for full-text search.","messagePattern":"Property '(.+?)\\.(.+?)' was configured for full-text search, but has type '(.+?)'; only string properties can be configured for full-text search\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs","lineNumber":250,"sourceCode":"                        ? CompositePathSortOrder.Descending\n                        : CompositePathSortOrder.Ascending;\n                    compositePaths.Add(new CompositePath { Path = path, Order = order });\n                    key.Append(path).Append('=').Append(order).Append('|');\n                }\n\n                if (seenCompositeIndexes.Add(key.ToString()))\n                {\n                    compositeIndexes.Add(compositePaths);\n                }\n            }\n        }\n\n        var fullTextPaths = new Collection<FullTextPath>();\n        foreach (var (property, language) in parameters.FullTextProperties)\n        {\n            if (property.ClrType != typeof(string))\n            {\n                throw new InvalidOperationException(\n                    CosmosStrings.FullTextSearchConfiguredForUnsupportedPropertyType(\n                        property.DeclaringType.DisplayName(),\n                        property.Name,\n                        property.ClrType.Name));\n            }\n\n            fullTextPaths.Add(\n                new FullTextPath\n                {\n                    Path = GetJsonPropertyPathFromRoot(property),\n                    // TODO: remove the fallback once Cosmos SDK allows optional language (see #35939)\n                    Language = language ?? parameters.DefaultFullTextLanguage ?? \"en-US\"\n                });\n        }\n\n        var embeddings = new Collection<Embedding>();\n        foreach (var (property, vectorType) in parameters.Vectors)\n        {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs#L232-L268","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmodelBuilder.Entity<Document>()\n    .Property(d => d.FileSize)  // int\n    .IsFullTextSearch();\n\n// after\nmodelBuilder.Entity<Document>()\n    .Property(d => d.Content)   // string\n    .IsFullTextSearch();","handlingStrategy":"validation","validationCode":"// Validate that every full-text-search-enabled property is a string.\nforeach (var entityType in model.GetEntityTypes())\n{\n    foreach (var property in entityType.GetProperties())\n    {\n        if (property.GetIsFullTextSearchEnabled() == true && property.ClrType != typeof(string))\n            throw new InvalidOperationException($\"{property.Name} is full-text but not a string.\");\n    }\n}","typeGuard":"// Guard: only enable full-text search on string properties\nstatic void ConfigureFullText<T>(EntityTypeBuilder<T> eb, Expression<Func<T, string>> prop)\n    where T : class\n    => eb.HasIndex(prop).ForCosmos().IsFullTextIndex();","tryCatchPattern":null,"preventionTips":["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."],"tags":["cosmos","full-text-search","model-configuration","type-mismatch"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}