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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.