The error is
The instance of entity type ‘Person’ cannot be tracked because another instance with the same key value for {‘Id’} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using
This is my code:
public async Task<Person> GetPersonById(Guid Id)
{
return await _context.Person.AsNoTracking()
.Where(t => t.Id == Id).FirstOrDefaultAsync();
}
public async Task<Guid> EditPerson(Person Updateperson)
{
if (Updateperson.Id != null)
{
Updateperson.ModifiedOn = DateTime.Now;
Updateperson.ModifiedBy = Updateperson.CreatedBy;
_context.Update(Updateperson);
await _context.SaveChangesAsync();
return Updateperson.Id;
}
else
{
return Guid.Empty;
}
}
In the Blazor single page application, when I edit the same record twice without a hard refresh, it will not update the record the second time.
Can anyone provide a solution for this?