https://github.com/caffeinatedcoder/efcore.complexindexes
Index support for complex type properties in EF Core migrations — the missing piece for value object-driven architectures.
https://github.com/caffeinatedcoder/efcore.complexindexes
dbmigration efcore efcore-extension entityframeworkcore-migrations
Last synced: 4 months ago
JSON representation
Index support for complex type properties in EF Core migrations — the missing piece for value object-driven architectures.
- Host: GitHub
- URL: https://github.com/caffeinatedcoder/efcore.complexindexes
- Owner: CaffeinatedCoder
- License: mit
- Created: 2026-02-11T14:30:03.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-02-14T13:18:38.000Z (4 months ago)
- Last Synced: 2026-02-14T15:49:29.287Z (4 months ago)
- Topics: dbmigration, efcore, efcore-extension, entityframeworkcore-migrations
- Language: C#
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/EFCore.ComplexIndexes/)
## 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** | [](https://www.nuget.org/packages/EFCore.ComplexIndexes/) | Core library — single-column, composite, unique, and filtered indexes on complex type properties. Works with any EF Core relational provider. |
| **EFCore.ComplexIndexes.PostgreSQL** | [](https://www.nuget.org/packages/EFCore.ComplexIndexes.PostgreSQL/) | PostgreSQL extensions via [Npgsql](https://www.npgsql.org/efcore/) — 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:
``` csharp
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);
```
The package integrates seamlessly with EF Core's design-time tooling, requiring zero additional ceremony—just configure and migrate.