-
-
Notifications
You must be signed in to change notification settings - Fork 147
Description
for example if your entity has property same as
public ICollection<DiseaseAttachment> Attachments { get; set; }
in update method in your controller you must load it by using LoadCollectionAsync
in my usecase :
var model = await Repository.GetByIdAsync(cancellationToken, dto.Id); await Repository.LoadCollectionAsync(model, x => x.Attachments, cancellationToken);
but problem is here that exception occurred
`
model = dto.ToEntity(Mapper, model);
await Repository.UpdateAsync(model, cancellationToken);
`
exception is this :
System.InvalidOperationException : The instance of entity type 'DiseaseAttachment
' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attac
hing existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbC
ontextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values