首页 > 解决方案 > 为源类型“DbSet<>”找到了查询模式的多个实现。对“哪里”的模棱两可的呼唤

问题描述

我正在使用 EF Core 3.1.2,但出现以下错误

using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


public async Task<List<Client>> GetClients()
{
      return await (from client in context.Client
                    select client).ToListAsync();
}
Multiple implementations of the query pattern were found for source type 'DbSet<>'. Ambiguous call to 'Where'
Multiple implementations of the query pattern were found for source type 'DbSet<>'. Ambiguous call to 'Select'
I get Ambiguous invocation:

System.Collections.Generic<IAsyncEnumerable>
System.Collections.Generic<IEnumerable>
System.Collections.Generic<IQuerable>

我没有任何方法可以覆盖上述内容。

标签: c#.net.net-coreentity-framework-core

解决方案


根据这个github线程:https ://github.com/dotnet/efcore/issues/18124

当前的解决方法是调用AsQueryable()您的 DBSet。例如:

_context.YourDbSet.AsQueryable()


推荐阅读