EFCore.ComplexIndexes.PostgreSQL 2.0.0

dotnet add package EFCore.ComplexIndexes.PostgreSQL --version 2.0.0
                    
NuGet\Install-Package EFCore.ComplexIndexes.PostgreSQL -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EFCore.ComplexIndexes.PostgreSQL" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EFCore.ComplexIndexes.PostgreSQL" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EFCore.ComplexIndexes.PostgreSQL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EFCore.ComplexIndexes.PostgreSQL --version 2.0.0
                    
#r "nuget: EFCore.ComplexIndexes.PostgreSQL, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EFCore.ComplexIndexes.PostgreSQL@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EFCore.ComplexIndexes.PostgreSQL&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=EFCore.ComplexIndexes.PostgreSQL&version=2.0.0
                    
Install as a Cake Tool

Index support for complex type properties in EF Core migrations — the missing piece for value object-driven architectures.

EF Core 8.0 introduced complex properties, but migration tooling doesn't automatically generate indexes for these nested value objects. This NuGet package bridges that gap with a clean, fluent API for defining single-column, composite, unique, and filtered indexes directly on complex type properties.

Why it matters:

  • Value Object Indexing: Seamlessly add database indexes to properties buried inside complex types (e.g., Person.EmailAddress.Value)
  • DDD-Friendly: Supports the Domain-Driven Design pattern of encapsulating logic in value objects without sacrificing database performance
  • Migration-Aware: Automatically generates proper CREATE INDEX and DROP INDEX operations during EF Core migrations
  • Flexible Filtering: Supports SQL WHERE clauses for filtered indexes (e.g., soft deletes)
  • Composite Indexes: Define multi-column indexes spanning both scalar and nested properties with a single, intuitive expression
Package NuGet Description
EFCore.ComplexIndexes nuget Core library — single-column, composite, unique, and filtered indexes on complex type properties. Works with any EF Core relational provider.
EFCore.ComplexIndexes.PostgreSQL nuget PostgreSQL extensions via Npgsql — adds GIN, GiST, BRIN, SP-GiST, and Hash index methods, operator classes, covering indexes (INCLUDE), concurrent creation, and nulls-distinct control.

Which package do I need? Install only the core package if you use SQL Server, SQLite, or any provider where the default B-tree index type is sufficient. Add the PostgreSQL package when you need PostgreSQL-specific index types — it includes the core automatically.

Quick Example:

builder.ComplexProperty(x => x.EmailAddress, c => 
  c.Property(x => x.Value)
   .HasComplexIndex(isUnique: true, filter: "deleted_at IS NULL")
);

builder.HasComplexCompositeIndex(x => new { x.Name, x.EmailAddress.Value }, isUnique: true);

PostgreSQL Samples:

// GIN index on a JSONB complex property
builder.ComplexProperty(x => x.Metadata, c =>
    c.Property(x => x.Tags)
     .HasComplexIndex(ix => ix.UseGin())
);

// Unique GiST index with filter
builder.ComplexProperty(x => x.Location, c =>
    c.Property(x => x.Coordinates)
     .HasComplexIndex(ix => ix
         .IsUnique()
         .UseGist()
         .HasFilter("deleted_at IS NULL")
     )
);

// GIN with operator class
builder.ComplexProperty(x => x.Profile, c =>
    c.Property(x => x.Data)
     .HasComplexIndex(ix => ix
         .UseGin()
         .HasOperators("jsonb_path_ops")
     )
);

// Composite BRIN index
builder.HasComplexCompositeIndex(
    x => new { x.CreatedAt, x.Sensor.ReadingValue },
    ix => ix.UseBrin()
);

// Simple cases still work without the satellite
builder.ComplexProperty(x => x.Email, c =>
    c.Property(x => x.Value)
     .HasComplexIndex(isUnique: true)
);

The package integrates seamlessly with EF Core's design-time tooling, requiring zero additional ceremony—just configure and migrate.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 84 2/14/2026