遇到这个问题头疼好几天 , 找了N种方法,最终找到最快速 、最满意的解决方法。
1、通过nuget安装:EntityFrameworkCore.UseRowNumberForPaging
其中0.3.0仅支持 .net 6.0 及以上版本
其中0.2.0 和 0.1.0 支持 .net 5.0 及以上版本
2、在startup.cs 中引用
using EntityFrameworkCore.UseRowNumberForPaging;
3、修改EF配置
services.AddDbContext<DBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("SqlServer"), i => i.UseRowNumberForPaging()));
然后运行一切OK