A second operation was started on this context before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext

Hi,
I'm driving crazy about paging and adding removing rows into simple grid that was fully functionally in 18.1 and after update .net 5 and blazor 18.2, 18.3, 18.4 always get the error in the object.
For simple check here is attached the project in VS2019.

Attachment: blazortest_fe4644d0.zip

14 Replies 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team February 8, 2021 01:17 PM UTC

Hi Massimo, 

Greetings from Syncfusion support. 

We are facing some complexities in running your sample as we are unable to access your database so kindly share us the below details, 

  1. Share us the steps to run your application.
  2. Share us the video demo of the issue you are facing.
  3. Share us the script error/Exception details.

Also please bind the “OnActionFailure” event to Grid. This event will be triggered for every failure in Grid. Please share the details you get in the “args” of this event handler for further analysis. 

The above requested details will be helpful for us to validate the issue and provide you with a better solution as early as possible. 

Regards, 
Jeevakanth SP. 



MA Massimo February 8, 2021 04:53 PM UTC

Hi Jeevakanth,
the database backup for restore is included in the project: blazortest.bacpac
Here is the video and also adding OnActionFailure it does not fire.
Best regards,


Attachment: blazortest__Google_Chrome_20210208_175035_17a1a104.zip


JP Jeevakanth Palaniappan Syncfusion Team February 9, 2021 12:33 PM UTC

Hi Massimo, 

We have restored the database from the provided bacpac file but we are unable to access it. Please refer the below Exception for your reference. 

 


Based on the error in the shared video, we suspect that an asynchronous action is executing synchronously. So we suggest you to check the issue by setting the data asynchronously in the OnInitializedAsync method. 

Regards, 
Jeevakanth SP. 



MA Massimo February 9, 2021 04:30 PM UTC

Hi Jeevakanth,
you have to create the user into the server database with user "syncfusion" with password "syncfusion" , and delete/recreate ther syncfusion user db.
This credentials are into the appsettings.json.

I tried to make async the method OnInitialized() into the file TableItems.razor:  
protected override async void OnInitialized()
    {
        isLoading = true;
        colItems = await @Service.GetItems();
    }
but the compiled get into the error: 
'IQueryable<Items>' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'IQueryable<Items>' could be found

Best regards,


MA Massimo February 13, 2021 12:21 PM UTC

Hi Jeevakanth,
I solved the trouble.

changing the code:
public IQueryable<Items> GetItems()
        {
            return _context.Items
                .OrderByDescending(x => x.Id)
                .AsNoTracking();
        }
with:
 public Task<List<Items>> GetItems()
        {
            List<Items> list = new List<Items>(); 
            list = _context.Items
                .OrderByDescending(x => x.Id)
                .AsNoTracking().ToList();
            return Task.FromResult(list);
        }

Many thanks, attached is the solved solution.
Best Regards,

Attachment: blazortest_d44c179d.zip

Marked as answer

JP Jeevakanth Palaniappan Syncfusion Team February 15, 2021 05:33 AM UTC

Hi Massimo, 

We are glad to know that you have resolved your issue. Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 



SS Sergej Steinhauer replied to Massimo February 23, 2021 09:01 PM UTC

Hi Jeevakanth,
I solved the trouble.

changing the code:
public IQueryable<Items> GetItems()
        {
            return _context.Items
                .OrderByDescending(x => x.Id)
                .AsNoTracking();
        }
with:
 public Task<List<Items>> GetItems()
        {
            List<Items> list = new List<Items>(); 
            list = _context.Items
                .OrderByDescending(x => x.Id)
                .AsNoTracking().ToList();
            return Task.FromResult(list);
        }

Many thanks, attached is the solved solution.
Best Regards,

Attachment: blazortest_d44c179d.zip

Thank you for your example helped me too.


JP Jeevakanth Palaniappan Syncfusion Team February 24, 2021 05:37 AM UTC

Hi Sergej, 

We are glad that your problem has been solved. Please get back to us if you have any queries. 

Regards, 
Jeevakanth SP. 



MA maimoy July 26, 2021 01:14 AM UTC

I try to complete the SyncfusionHelpDesk described in book "Blazor succintly" source code following the steps in and i have this error.
After a lot of search and finallly replacing files one by one with the one published in github, i finally resolve this error about the second operation with access to dbcontext, by downgrading the latest by now syncfusion.blazor 19.2.0.48 to the one using the github published 18.1.0.42

I am new to syncfusion blazor so i don't know if the were so many changes to made this error happen with latest version

The latest working Syncfusion.Blazor package version that working according to book path for SyncfusionHelpDesk is 18.2.0.48



JP Jeevakanth Palaniappan Syncfusion Team July 26, 2021 01:07 PM UTC

Hi Maimoy, 

We have checked your query but before proceeding on this, we suggest you to share us the below details, 

  1. Does the reported problem is reproducing during initial rendering or performing any grid actions?
  2. Kindly share us the issue reproducing sample.

The above requested details will be helpful for us to validate the reported problem and to provide you with a better solution as early as possible. 

Regards, 
Jeevakanth SP. 



JI Jutta Ipsen July 29, 2021 08:16 PM UTC

Hi  Jeevakanth ,

I am running into the same error like  maimoy completing the  SyncfusionHelpDesk  sample.

I run into the error when selecting the "Edit" action with   syncfusion.blazor 19.2.0.48 


BR

Jutta



JI Jutta Ipsen July 29, 2021 09:23 PM UTC

Hi,

to fix the  SyncfusionHelpDesk  sample. 


  1. SyncfusionHelpDeskService.cs replace 
  2. public IQueryable<HelpDeskTickets> GetHelpDeskTickets ()

     

public Task<List<HelpDeskTickets>> GetHelpDeskTickets()

        {

            List<HelpDeskTickets> list = new List<HelpDeskTickets>();

            list = _context.HelpDeskTickets.AsNoTracking().ToList();

            return Task.FromResult(list);

        }


2. In Administrator.Razor comment out OnInitialized and overrride   OnInitializedAsync

 protected override async Task OnInitializedAsync()

        {

            isLoading = true;

            colHelpDeskTickets = await @Service.GetHelpDeskTickets();

        }



BR

Jutta



JP Jeevakanth Palaniappan Syncfusion Team July 30, 2021 10:42 AM UTC

Hi Jutta, 
 
Thanks for sharing the solution here. 
 
@Maimoy, please check the solution suggested by Jutta and get back to us if you need further assistance. 
 
Regards, 
Jeevakanth SP. 



Loader.
Up arrow icon