在使用NetCore2.2时,使用的数据库是sql server 2008,查询数据出现此错误。
解决方法:
在startup.cs或者Context重写的OnConfiguring中修改如下:
加上 “UseRowNumberForPaging()”
services.AddDbContext<OnlineContext>(optionsBuilder =>
{
optionsBuilder.UseSqlServer(conn, i =>
{
i.EnableRetryOnFailure();//可自定义失败重连次数
i.CommandTimeout(60);
i.UseRowNumberForPaging(); //Use a ROW_NUMBER() in queries instead of OFFSET/FETCH. This method is backwards-compatible to SQL Server 2005.
});
});
网友评论