0

我正在做一个 asp.net core 6.0 项目

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

当我尝试使用ILike时,

我收到了这个错误'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?)

using Microsoft.EntityFrameworkCore;也添加了参考。

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

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

为什么会出现这个错误?

4

1 回答 1

1

ILIKE关键字特定于 PostgreSQL,因此您需要使用 PostgreSQL 提供程序 ( Npgsql.EntityFrameworkCore.PostgreSQL ) 才能使用该EF.Functions.ILike函数。

于 2021-12-29T08:55:55.670 回答