【问题标题】:Hash Index on Pgsql table in EFCoreEF Core 中 Sql 表的哈希索引
【发布时间】:2021-08-02 16:49:00
【问题描述】:

如何在 Efcore fluent api 中为 pgsql db 指定索引类型为“hash”?

例如:

modelBuilder.Entity().HasIndex(u => u.PId).IsUnique();

是否有任何特定于接受索引类型的 pgsql 的扩展方法?正在创建的默认索引类型是“btree”。

【问题讨论】:

    标签: postgresql entity-framework-core ef-code-first ef-fluent-api


    【解决方案1】:

    您可以像这样使用HasMethod

    modelBuilder.Entity().HasIndex(u => u.PId).HasMethod("hash")
    

    按照postgres documentation的方法

    方法

    要使用的索引方法的名称。选项有 btree、hash、gist、spgist、gin 和 brin。默认方法是 btree。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-26
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-28
      相关资源
      最近更新 更多