Shyamal Parikh Shyamal Parikh - 8 days ago 10
C# Question

EF6: Full-text Search with Database First Approach

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
?

Relevant part of code:

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());
}
}


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

Answer

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.