Paging with Entity Framework 7 and SQL Server 2008

后端 未结 6 447
我寻月下人不归
我寻月下人不归 2020-12-08 10:35

I\'m trying to use paging (that is .Skip(...).Take(...) in Entity Framework 7. It works OK with Microsoft SQL Server 2012 and 2014, but fails with the following

6条回答
  •  隐瞒了意图╮
    2020-12-08 11:23

    I encountered this problem myself using EF 7 and sql server 2008. Fortunately in the latest rc1 version of EF 7 you can solve this by using .UseRowNumberForPaging() as shown in this example:

    services.AddEntityFramework()
      .AddSqlServer()
      .AddDbContext(options =>
         options.UseSqlServer(configuration["Data:DefaultConnection:ConnectionString"])
                        // this is needed unless you are on mssql 2012 or higher
                        .UseRowNumberForPaging()
                    );
    

提交回复
热议问题