''DbFunctions' does not contain a definition for 'ILike'

I am working a asp.net core 6.0 project

query = query.Where(d => EF.Functions.ILike(d.Id.ToString(), $"%{keyword}%"));

When I try to use ILike,

I got this error 'DbFunctions' does not contain a definition for 'ILike' and no accessible extension method 'ILike' accepting a first argument of type 'DbFunctions' could be found (are you missing a using directive or an assembly reference?)

I added reference using Microsoft.EntityFrameworkCore; too.

<PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
 </PropertyGroup>

 <ItemGroup>
     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
</ItemGroup>

Why this error occurs?



Solution 1:[1]

The ILIKE keyword is specific to PostgreSQL, so you need to use the PostgreSQL provider (Npgsql.EntityFrameworkCore.PostgreSQL) for the EF.Functions.ILike function to be available.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 0xced