can't add records if use lazy loading

Hi,

my development-environment: visualstudio 2022, net-framework 4.8, entity framework core 3


I use the SfDataGrid to display data from a MySQL database (2 tables, 1:n relationship). I use the EntityFramwork with activated LazyLoading as data model.

LazyLoading, because I do not want to explicitly load the 1:n data via .Include(“”) etc..

Reading / displaying is no problem at all, it works wonderfully.


But, I cannot add new data records (neither via AddNewRow, nor via code .Add(...)), here I always get the error:

Example: “The object with the type ‘BookEntryItem’ cannot be converted to the type ‘Castle.Proxies.BookEntryItemProxy’”


Do you have a small example for a sfdatagrid in combination with entity framework, lazyloading and add records?

Or is it not possible to add a record if LazyLoading is activated, but I have not found any information at Microsoft or in other forums.

many greetings Danie


1 Reply

SP Sreemon Premkumar Muthukrishnan Syncfusion Team October 21, 2024 06:22 PM UTC

Hi Daniel,


Currently, we do not have a sample that meets your requirement of loading the SfDataGrid with two DataTables using Entity Framework with LazyLoading enabled. Before making further progress on creating a sample, we would like some clarification regarding the information provided. Could you please share more details about your implementation with the SfDataGrid and the reason for using lazy loading to avoid explicit loading?

Additionally, could you please provide the following information:

  1. Could you share any video references that demonstrate the issue when adding new rows to the SfDataGrid?
  2. Could you provide details on the BookEntryItem and BookEntryItemProxy types?
  3. Are you trying to cast these types? If so, please share more details on how the casting error is related to the SfDataGrid.

We already have a sample that uses the SfDataGrid with Entity Framework where new rows are added correctly. You can find this sample in the attachment.


Regards,
Sreemon Premkumar M.


Attachment: CRUD_Entity_Framework_de00dea8.zip

Loader.
Up arrow icon