{"record":{"id":"52b86c338d9e19c2","repo":"dotnet/efcore","slug":"a-full-text-index-is-defined-for-entitytype-pr","errorCode":null,"errorMessage":"A full-text index is defined for `{entityType}.{property}`, but full-text search was not enabled for this property. Use '{enableFullText}' method in 'OnModelCreating' to enable full-text search for this property.","messagePattern":"A full-text index is defined for `(.+?)\\.(.+?)`, but full-text search was not enabled for this property\\. Use '(.+?)' method in 'OnModelCreating' to enable full-text search for this property\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs","lineNumber":652,"sourceCode":"    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    protected virtual void ValidateFullTextIndex(\n        IIndex index,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        if (index.Properties.Count > 1)\n        {\n            throw new InvalidOperationException(\n                CosmosStrings.CompositeFullTextIndex(\n                    index.DeclaringEntityType.DisplayName(),\n                    string.Join(\",\", index.Properties.Select(e => e.Name))));\n        }\n\n        if (index.Properties[0] is not IProperty firstFullTextProperty\n            || firstFullTextProperty.GetIsFullTextSearchEnabled() != true)\n        {\n            throw new InvalidOperationException(\n                CosmosStrings.FullTextIndexOnNonFullTextProperty(\n                    index.DeclaringEntityType.DisplayName(),\n                    index.Properties[0].Name,\n                    nameof(CosmosPropertyBuilderExtensions.EnableFullTextSearch)));\n        }\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    protected override void ValidateProperty(\n        IProperty property,\n        ITypeBase structuralType,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs#L634-L670","documentation":"Thrown by CosmosModelValidator.ValidateFullTextIndex when a full-text index targets a property that does not have full-text search enabled. The check requires index.Properties[0] to be an IProperty with GetIsFullTextSearchEnabled() == true; that annotation is set by CosmosPropertyBuilderExtensions.EnableFullTextSearch().","triggerScenarios":"Calling HasFullTextIndex() on an index without first calling EnableFullTextSearch() on the indexed property, or disabling full-text on a property that still has a full-text index attached.","commonSituations":"Adding HasFullTextIndex during a refactor but forgetting the matching EnableFullTextSearch call; toggling full-text off while leaving the index in place.","solutions":["Call entityTypeBuilder.Property(p => p.Text).EnableFullTextSearch() in OnModelCreating for the property named in the error.","Remove the HasFullTextIndex() call if you no longer intend the property to be full-text searchable.","Re-validate the model to confirm both annotations agree."],"exampleFix":"// before\nmodelBuilder.Entity<Article>(b =>\n{\n    b.HasIndex(a => a.Body).HasFullTextIndex();\n});\n\n// after\nmodelBuilder.Entity<Article>(b =>\n{\n    b.Property(a => a.Body).EnableFullTextSearch();\n    b.HasIndex(a => a.Body).HasFullTextIndex();\n});","handlingStrategy":"validation","validationCode":"// Ensure every full-text index targets an enabled property.\nforeach (var et in modelBuilder.Model.GetEntityTypes())\nforeach (var idx in et.GetIndexes().Where(i => i.IsFullTextIndex()))\n    if (idx.Properties[0].GetIsFullTextSearchEnabled() != true)\n        throw new InvalidOperationException($\"Property {idx.Properties[0].Name} needs EnableFullTextSearch().\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make EnableFullTextSearch() and HasFullTextIndex() a matched pair in the configuration.","When disabling full-text on a property, also remove its full-text index.","Add a startup assertion that cross-checks the two annotations."],"tags":["cosmos","full-text-search","model-validation","configuration"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}