【问题标题】:Entity Framework Core 7 Full Text Search Index AnnotationEntity Framework Core 7 全文搜索索引注解
【发布时间】:2023-02-03 02:08:41
【问题描述】:

有没有办法用 Entity Framework Core 7 注释类中的字符串字段以在该列上创建全文索引,如果是,我如何使用 EF Core 7 运行查询来搜索该列?

我不是在要求流畅的 API,而是在我的 C# 类中要求字段注释。

【问题讨论】:

    标签: c# entity-framework-core full-text-search ef-core-7.0


    【解决方案1】:

    你可以这样使用:

    [Index(nameof(Url))]
    public class Blog
    {
        public int BlogId { get; set; }
        public string Url { get; set; }
    }
    

    如果你想要复合索引:

    [Index(nameof(FirstName), nameof(LastName))]
    public class Person
    {
        public int PersonId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
    

    参考:https://learn.microsoft.com/en-us/ef/core/modeling/indexes?tabs=data-annotations

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-11
      • 2020-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-21
      • 1970-01-01
      • 2018-10-26
      相关资源
      最近更新 更多