Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Syntaxe incorrecte près de 'OFFSET'. Utilisation non valide de l'option NEXT dans l'instruction FETCH dans le noyau Entity Framework

Il existe un paramètre de compatibilité (UseRowNumberForPaging ) pour cela qui peut être configuré soit dans le DbContext lui-même :

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        var coonectionString = "Data Source=localhost\\MSSQLSERVER01;Initial Catalog=AppDb01;Integrated Security=True";
        optionsBuilder.UseSqlServer(coonectionString, builder => builder.UseRowNumberForPaging());
    }

Ou dans le cadre de la Startup :

    public void ConfigureServices(IServiceCollection services)
    {
        var coonectionString = "Data Source=localhost\\MSSQLSERVER01;Initial Catalog=AppDb01;Integrated Security=True";
        services.AddDbContext<AppDbContext>(options => options.UseSqlServer(coonectionString, builder => builder.UseRowNumberForPaging()));
    }