dotnet/efcore · error · InvalidOperationException

A full-text index is defined for

Error message

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.

What it means

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().

Solutions

  1. Call entityTypeBuilder.Property(p => p.Text).EnableFullTextSearch() in OnModelCreating for the property named in the error.
  2. Remove the HasFullTextIndex() call if you no longer intend the property to be full-text searchable.
  3. Re-validate the model to confirm both annotations agree.

Example fix

// before
modelBuilder.Entity<Article>(b =>
{
    b.HasIndex(a => a.Body).HasFullTextIndex();
});

// after
modelBuilder.Entity<Article>(b =>
{
    b.Property(a => a.Body).EnableFullTextSearch();
    b.HasIndex(a => a.Body).HasFullTextIndex();
});
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every full-text index targets an enabled property.
foreach (var et in modelBuilder.Model.GetEntityTypes())
foreach (var idx in et.GetIndexes().Where(i => i.IsFullTextIndex()))
    if (idx.Properties[0].GetIsFullTextSearchEnabled() != true)
        throw new InvalidOperationException($"Property {idx.Properties[0].Name} needs EnableFullTextSearch().");

Prevention

When it happens

Trigger: 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.

Common situations: Adding HasFullTextIndex during a refactor but forgetting the matching EnableFullTextSearch call; toggling full-text off while leaving the index in place.

Related errors


AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11). Data as JSON: /api/errors/52b86c338d9e19c2. Report an issue: GitHub.

Appendix: source

Thrown at src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs:652

    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    protected virtual void ValidateFullTextIndex(
        IIndex index,
        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
    {
        if (index.Properties.Count > 1)
        {
            throw new InvalidOperationException(
                CosmosStrings.CompositeFullTextIndex(
                    index.DeclaringEntityType.DisplayName(),
                    string.Join(",", index.Properties.Select(e => e.Name))));
        }

        if (index.Properties[0] is not IProperty firstFullTextProperty
            || firstFullTextProperty.GetIsFullTextSearchEnabled() != true)
        {
            throw new InvalidOperationException(
                CosmosStrings.FullTextIndexOnNonFullTextProperty(
                    index.DeclaringEntityType.DisplayName(),
                    index.Properties[0].Name,
                    nameof(CosmosPropertyBuilderExtensions.EnableFullTextSearch)));
        }
    }

    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    protected override void ValidateProperty(
        IProperty property,
        ITypeBase structuralType,
        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
    {

View on GitHub (pinned to 3a2006ef56)