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”.
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 same record twice without hard refresh it will not update the record 2nd time. Can anyone provide me the solution for this?