-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FREETEXT search on a ntext column not working #31583
Comments
Note for triage: If the column is using (var context = new SomeDbContext())
{
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
context.Database.ExecuteSqlRaw(@"CREATE FULLTEXT CATALOG ft AS DEFAULT");
context.Database.ExecuteSqlRaw(@"CREATE FULLTEXT INDEX ON dbo.Name(Title, Recommendation) KEY INDEX PK_Name");
}
using (var context = new SomeDbContext())
{
var searchText = "woman";
var results = context.Set<Name>().AsNoTracking().Where(x => (x.Title != null && EF.Functions.FreeText(x.Title, searchText)) ||
(x.Recommendation != null &&
EF.Functions.FreeText(x.Recommendation, searchText))).ToList();
}
public class SomeDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer(@"Data Source=AVICKERS420L;Database=AllTogetherNow;Integrated Security=True;Connect Timeout=60;ConnectRetryCount=0;TrustServerCertificate=True")
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
// "AllTogetherNow")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Name>(b =>
{
b.Property(e => e.Recommendation).HasColumnType("ntext");
b.Property(e => e.Title).HasColumnType("nvarchar(256)");
});
}
}
public class Name
{
public Guid Id { get; set; }
public string? Recommendation { get; set; }
public string? Title { get; set; }
} |
Note from triage: it is possible that the parameter inference is being used for the second parameter as well as the first, but the second parameter should always be |
Note from triage: this doesn't meet the servicing bar. |
File a bug
The SQL statement generated by the EF Core (displayed in the logs) for EF.Functions.FreeText function is correct and executes successfully. However, the actual statement that is sent to SQL server is different and throws the error.
freeText parameter type for ntext column in SQL statement is set to a size of 4000 but the SQL statement that is executed on SQL server parameter type is ntext and throws exception.
Include your code
Database Table: ComplaintRecommendation
Include stack traces
The parameter @__searchText_1_1 has size set to 4000 and above statement works if executed on the SQL Server
SQL Profiler Trace
Include provider and version information
EF Core version: 7.0.10
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: Windows 11
SQL Server: Microsoft SQL Server 2022 16.0.1050.5 (X64) Developer Edition (64-bit)
IDE: Visual Studio 2022 17.6.5
The text was updated successfully, but these errors were encountered: