How to find the tracked entity

This code is the edited version of this demo, which added ActionCompleteHandler and​ @inherits OwningComponentBase<MyService> . When defining ActionCompleteHandler​'s Service.Update(entity) in MyService, I noticed that that I cannot edit entity's data. If I want to further edit that data in MyService, how should I define my Update function? For your reference, I noticed that the entity I received in my MyService's update function is in Detached state. Also, simply have db.SaveChanges() in my Update function, EF Core can already track changes and update the database. Below is my Update function:

        public void Update(ScheduleData.DoctorsEventData entity)
        {
            try
            {
                var data = db.doctorsevents.FirstOrDefault(entry => entry.Id.Equals(entity.Id));
                if (data != null)
                {
                    db.Entry(data).State = EntityState.Detached;
                }
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch
            {
                throw;
            }
        }

I am using NET 6.


1 Reply 1 reply marked as answer

VR Vijayakumar Rajasekar Syncfusion Team May 19, 2026 05:46 AM UTC

Hi desmond,

Thank you for sharing the details of your scenario and your current approach. We understand that you want to edit entity data (such as the subject) and have those changes reflected in the UI, without requiring a manual refresh of the scheduler. Based on our review, we recommend using a custom data adapter for your Scheduler component.
The reason for this recommendation is that, in your current setup (without a data adapter), the entity you receive in your service is in a Detached state. This means Entity Framework Core is not tracking changes to the entity, which can make it difficult to update the UI seamlessly after making changes in the database. As a result, you currently need to refresh the scheduler manually to see updates.
By implementing a custom data adapter, you can manage data operations (such as CRUD actions) more efficiently and ensure that changes made to your entities are immediately reflected in the Scheduler UI. The custom adapter approach allows you to handle data binding and updates in a way that keeps the UI and database in sync, eliminating the need for manual refreshes.


    <ScheduleEventSettings TValue="AppointmentData">
        <SfDataManager AdaptorInstance="@typeof(AppointmentDataAdaptor)" Adaptor="Adaptors.CustomAdaptor">
        </SfDataManager>
    </ScheduleEventSettings>
We recommend reviewing the following documentation for guidance on implementing a custom data adapter:
This guide provides step-by-step instructions on how to set up a custom data adapter, handle CRUD operations, and ensure that your Scheduler component stays up-to-date with the latest data from your database.
Additionally, we have prepared a sample based on your scenario for your reference. The below command is required to apply the Entity Framework Core migrations and create the necessary database schema before running the application.


Update-Database


Kindly review the sample, and please reach out with additional details if your query was different or if you need further assistance.


Regards,

Vijayakumar R


Attachment: blazorschedulerloadappointmentsondemand_51cb4096.zip

Marked as answer
Loader.
Up arrow icon