本文介绍了EF6:使用数据库首选方法进行全文搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个使全文搜索通过 linq 工作。但是,代码似乎是针对数据库第一个方法。如何使用数据库优先方法

I found this link to make full-text search work through linq. However, the code seems to be targeting database first approach. How to make it work with Database First Approach?

代码的相关部分:

public class NoteMap : EntityTypeConfiguration<Note>
{
    public NoteMap()
    {
        // Primary Key
        HasKey(t => t.Id);
    }
}
public class MyContext : DbContext
{
    static MyContext()
    {
        DbInterception.Add(new FtsInterceptor());
    }
    public MyContext(string nameOrConnectionString) : base(nameOrConnectionString)
    {
    }
    public DbSet<Note> Notes { get; set; }
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Configurations.Add(new NoteMap());
    }
}

如上所述,函数 OnModelCreating 仅在 Code First Approach 中调用。我不知道需要改变什么才能使链接中的代码工作在 Database First 方法

As seen above the function OnModelCreating is only called in Code First Approach. I wonder what needs to change to make the code in link work for Database First approach

推荐答案

好的,我试图实现没有$ code> OnModelCreating 的解决方案,结果是,甚至不需要 FullText 拦截器实现为@Evk建议。

Ok, I tried implementing the solution without OnModelCreating altogether and it turns out that it is not even needed for FullText interceptor implementation as @Evk suggested.

这篇关于EF6:使用数据库首选方法进行全文搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 03:46