postgresql - 可以使用 POSTGRESQL 在 Code First Entity Framework 中指定 JSONB GIN 索引吗?

标签 postgresql entity-framework npgsql

我在 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/

相关文章:

postgresql - 退出 postgres UNIX 帐户

.net - 在表达式中包含方法类

entity-framework - 我可以从特定的迁移中解码 Entity Framework 模型吗?

c# - NpgsqlDataReader - 将空值与 "NULL"文字区分开来

sql - Postgresql如何从文本数据中获取指定的文本

postgresql - 是否可以在 postgresql 中使用 for 循环(功能)

c# - Entity Framework 导航属性上的 OrderBy(一对多)

c# - 在 Npgsql 中获取数据库列表

c# - 如果 NodaTime 使用 Duration 而 Postgres 使用 INTERVAL/Period,如何在 EF Core 中进行时间戳运算?

postgresql - 如何使用不在当前范围内的 lead() 值进行查询