我在 EFCore 项目中的 EF 代码优先对象上有一些 JSONB 列。我想为那些存储为 JSONB 属性/列的强类型对象中的属性设置一些 GIN 索引。
这可能吗? (当前使用 postgres:latest 图像)
谢谢。
最佳答案
由于 .ForNpgsqlHasMethod("gin")
已过时,对于 EF Core 3.1,您可以使用它:
metaBuilder
.HasIndex(x => x.DocumentNumber)
.HasMethod("gin")
.HasOperators("gin_trgm_ops");
您的迁移将如下所示:
migrationBuilder.CreateIndex(
name: "IX_DocumentContentMeta_DocumentNumber",
table: "DocumentContentMeta",
column: "DocumentNumber")
.Annotation("Npgsql:IndexMethod", "gin")
.Annotation("Npgsql:IndexOperators", new[] { "gin_trgm_ops" });
关于postgresql - 可以使用 POSTGRESQL 在 Code First Entity Framework 中指定 JSONB GIN 索引吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54618858/