Skip to content

Commit 1f49ab1

Browse files
committed
Add docs on ForNpgsqlHasIndexMethod
(cherry picked from commit e678c24)
1 parent 2337922 commit 1f49ab1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

doc/misc.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ To enable this feature on an entity, insert the following code into your model's
2323
modelBuilder.Entity<MyEntity>().ForNpgsqlUseXminAsConcurrencyToken();
2424
```
2525

26+
## PostgreSQL Index Methods
27+
28+
PostgreSQL supports a number of _index methods_, or _types_. These are specified at index creation time via the `USING _method_` clause, see the [PostgreSQL docs for `CREATE INDEX`](https://www.postgresql.org/docs/current/static/sql-createindex.html) and [this page](https://www.postgresql.org/docs/current/static/indexes-types.html) for info on the different types.
29+
30+
The Npgsql EF Core provider allows you to specify the index method to be used by specifying `ForNpgsqlHasMethod()` on your index in your context's OnModelCreating:
31+
```c#
32+
protected override void OnModelCreating(ModelBuilder modelBuilder) {
33+
modelBuilder.Entity<Blog>()
34+
.HasIndex(b => b.Url)
35+
.ForNpgsqlHasMethod("gin");
36+
}
37+
```
38+
2639
## Execution Strategy
2740

2841
Since 2.0.0, the Npgsql provider provides a retrying execution strategy, which will attempt to detect most transient PostgreSQL/network errors and will automatically retry your operation. To enable, place the following code in your context's `OnModelConfiguring`:
@@ -67,7 +80,7 @@ which will be copied as the basis for the new one. This can be useful for includ
6780
modelBuilder.HasDatabaseTemplate("my_template_db");
6881
```
6982

70-
# CockroachDB Interleave In Parent
83+
## CockroachDB Interleave In Parent
7184

7285
If you're using CockroachDB, the Npgsql provider exposes its ["interleave in parent" feature](https://www.cockroachlabs.com/docs/stable/interleave-in-parent.html). Use the following code:
7386

0 commit comments

Comments
 (0)