原因是sqlserver2008不支持此語法
一般修改方法:修改“StartUp.cs”文件
public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); var connection = @"Data Source=.; Initial Catalog=xxx;Persist Security Info=True;User ID=xxxx;Password=xxxxx"; services.AddDbContext<NoteContext>(options => options.UseSqlServer(connection, b => b.UseRowNumberForPaging())); services.AddScoped<Repository.INoteRepository, Repository.NoteRepository>(); services.AddScoped<Repository.INoteTypeRepository, Repository.NoteTypeRepository>(); }
abp修改方法:修改DbContextConfigurer
public static class PhoneBookDbContextConfigurer { public static void Configure(DbContextOptionsBuilder<PhoneBookDbContext> builder, string connectionString) { builder.UseSqlServer(connectionString, b => b.UseRowNumberForPaging());//解決sqlserver2008不支持FETCH、NEXT } public static void Configure(DbContextOptionsBuilder<PhoneBookDbContext> builder, DbConnection connection) { builder.UseSqlServer(connection, b => b.UseRowNumberForPaging());//解決sqlserver2008不支持FETCH、NEXT } }