How can I stop EF Core from creating a filtered index on a nullable column

Creating filtered index excluding NULL values is the default EF Core behavior for unique indexes containing nullable columns.

You can use HasFilter fluent API to change the filter condition or turn it off by passing null as sql argument:

entityBuilder.HasIndex(e => new { e.LevelId, e.Name, e.DeletedAt })
    .IsUnique()
    .HasFilter(null);

Leave a Comment