【发布时间】:2020-02-22 00:38:12
【问题描述】:
我在 DbSet<T> 上使用 LINQ 查询:
await _dbContext.Users.AnyAsync(u => u.Name == name);
但是,编译器会输出以下错误:
Error CS0121: The call is ambiguous between the following methods or properties:
'System.Linq.AsyncEnumerable.AnyAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>)' and
'Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AnyAsync<TSource>(System.Linq.IQueryable<TSource>, System.Linq.Expressions.Expression<System.Func<TSource, bool>>)'
其他 LINQ 扩展方法也会出现类似问题,例如 .Where()。
我正在使用 EF.Core 3.1 并安装了 System.Linq.Async 包。我该如何解决这个问题?
【问题讨论】:
标签: c# linq entity-framework-core ambiguous entity-framework-core-3.1