遇到这个问题头疼好几天 , 找了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
本文介绍如何在.NET 6.0及以上版本中通过NuGet安装EntityFrameworkCore.UseRowNumberForPaging扩展,详细步骤包括添加引用和配置DbContext,解决数据库分页需求。
963

被折叠的 条评论
为什么被折叠?



