MOHAMMEDSHIYASPA-3750 avatar image
0 Votes"
MOHAMMEDSHIYASPA-3750 asked JackJJun-MSFT commented

Entity Framework very slow compared to SQL Query


I have a Stored Procedure which returns the result within a second.
When I call the stored procedure from my Web API it takes at least 15 seconds to return the data. Sometimes goes upto few minutes.
I am using the below method. It returns around 15000 records with size around 2 MB.

public async Task<IEnumerable<Find>> GetFinds(int level)
var finds = _context.Finds.FromSqlRaw<Find>("sp_SHT_SelectAllValuesGivenLevels_Find {0}", level).ToListAsync();
return await finds;


public class Find
public string ID { get; set; }
public string Description { get; set; }


public class PHTDbContext : DbContext
public PHTDbContext(DbContextOptions<PHTDbContext> options) : base(options)
public DbSet<Find> Finds { get; set; }

I am redesigning the application from ASP.Net WebForms to ASP.Net Core Web API + Angular.
The redesign should make the application faster but it is slowing down.
Please help me with this.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MOHAMMEDSHIYASPA-3750, Welcome to Microsoft Q&A, I suggest that you could refer to the doc Run SQL Server Profiler to use SQL Server Profiler to detect what the database did when you execute the sql raw query in the ef.

0 Votes 0 ·

0 Answers