Q:

.NET Core DbContext block subsequent requests

We have a web application written in .Net Core (currently v2.2), and with Angular as frontend. 
If I do an ajax-call to one route in the backend which in turn opens up a dbcontext to perform a query, we are experiencing that all subsequent ajax-calls to any other route is getting held up until the query of the first controller route is done. (no, its not a DB Lock in the SQL server. Its different tables).
Example of the code in the first route (which, for the purpose of the example say takes 20 seconds):
public IActionResult GetBusinessesByNaceAndAmount(int take)
{
    using (ConsumentContext consumentContext = new ConsumentContext())
    {
        var data = consumentContext.Businesses.AsNoTracking().Where(b => b.Established_date != null).GroupBy(b => new { Code = b.Business_code.Substring(0, 2) }).Select(b => new
        {
            BusinessName = b.First().Business_code.Substring(0, 2),
            Businesses = b.Where(bl => bl.Established_date != null).OrderBy(bl => bl.Established_date).Select(bl => new { BusinessName = bl.Name, Amount = 10 }).Take(10).ToList(),
        }).Take(take).ToList();

        return Ok(data );
    }
}

Then, I perform another call to this, one millisecond later in the frontend:
public IActionResult GetCustomers()
{
    using (ConsumentContext consumentContext = new ConsumentContext())
    {
        var customers = consumentContext.Customers.AsNoTracking().Take(5).ToList();
        return Ok(customers);
    }
}

Even though the query of the second endpoint only takes a few milliseconds, its TTFB is held up until the first one is done. 
I don't know if it has anything to do with it, but our backend is currently running in a linux environment (Docker container), and is communicating via TCP/IP to our MSSQL server (yes, its locked down in firewall). 

A:

Your problem looks like either your server is running out of free threads to process action or in your Angular application you are not making API calls simultaneously but sequentially.
To free threads in a long running DB call, you can try changing your first action to an async action so the thread is not freezed, e.g.
public async Task<IActionResult> GetBusinessesByNaceAndAmount(int take, CancellationToken token)
{
    using (ConsumentContext consumentContext = new ConsumentContext())
    {
        var data = await consumentContext.Businesses
            .AsNoTracking()
            .Where(b => b.Established_date != null)
            .GroupBy(b => new { Code = b.Business_code.Substring(0, 2) })
            .Select(b => new
            {
                BusinessName = b.First().Business_code.Substring(0, 2),
                Businesses = b.Where(bl => bl.Established_date != null)
                    .OrderBy(bl => bl.Established_date)
                    .Select(bl => new { BusinessName = bl.Name, Amount = 10})
                    .Take(10).ToList(),
            })
            .Take(take)
            .ToListAsync(token);

        return Ok(data);
    }
}

This could help if your server is running out of threads to process the action. 
You can also verify your Angular code. If your application is waiting for the result of the first API call, then above code won't help - you should make all the calls simultaneously.

