Issue with Telerik grid and Entity Framework Core (.NET)

1 Answer 240 Views
ModalView View
Jack
Top achievements
Rank 1
Jack asked on 06 Dec 2021, 12:39 PM | edited on 16 Dec 2021, 04:00 AM

Hi all,

I started working with Blazor few weeks ago and recently got introduced to Telerik UI for Blazor so I started making a CRUD to learn.

After coding the update function I tested the app and got this error when I tried to update a register:

The instance of entity type 'Familia' cannot be tracked because another instance with the same key value for {'CodiFamilia'} is already being tracked.

To solve that I added "AsNoTracking" to the Entity Framework Core query located in "ReadList", it worked the first time but the app crashed after the second update. Afterwards I implemented an alternative solution which consists on finding the object by its ID and updating every parameter one by one which worked since it's not using the same object.

I'm wondering if there is any way to implement a functional update which resembles the first solution because the second one is pretty bad if there are many parameters to update azarshagle.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Svetoslav Dimitrov
Telerik team
answered on 09 Dec 2021, 10:08 AM

Hello Jack,

The Telerik UI for Blazor Grid is a data-agnostic component, which means that it is not reliant on the data source or how the data source itself is populated. The issue you are facing seems to be connected to the Entity Framework itself. I have conducted research on the topic and it seems that there are numerous questions in various .NET forums. Could you check some of the discussions in StackOverflow, the answer in this discussion, the issue created in the EFCore GitHub, and see if you can find a suitable solution in those discussions and forums. 

Regards,
Svetoslav Dimitrov
Progress Telerik

Learn about the important changes coming in UI for Blazor 3.0 in January 2022!
Tags
ModalView View
Asked by
Jack
Top achievements
Rank 1
Answers by
Svetoslav Dimitrov
Telerik team
Share this question
or