✅ EF Core 8: System.InvalidOperationException: 'The instance of entity type cannot be tracked..
Hi guys, I'm getting this error
but the thing is for the query where OccurrenceRule is loaded, I'm using AsNoTracking() method since there won't be any changes for that entity anyways.
the first method loads a list of StaffMembers along with the neccessary navigation properties, where this is also included:
and I can see that right after that method, if I call dbContext.ChangeTracker.Entries() it throws this error initially in quickwatch, and if I evaluate it again, it shows the list of entries.
if I continue the code execution after it shows the list of entries. I do NOT run into this error at all and the full operation/endpoint completes successfully.
I was under the impression that if I use .AsNoTracking when loading the data, those entries should not be added to the DbContext.ChangeTracker at all
I get the error when I call dbContext.SaveChanges();
any ideas?
but the thing is for the query where OccurrenceRule is loaded, I'm using AsNoTracking() method since there won't be any changes for that entity anyways.
the first method loads a list of StaffMembers along with the neccessary navigation properties, where this is also included:
and I can see that right after that method, if I call dbContext.ChangeTracker.Entries() it throws this error initially in quickwatch, and if I evaluate it again, it shows the list of entries.
if I continue the code execution after it shows the list of entries. I do NOT run into this error at all and the full operation/endpoint completes successfully.
I was under the impression that if I use .AsNoTracking when loading the data, those entries should not be added to the DbContext.ChangeTracker at all
I get the error when I call dbContext.SaveChanges();
any ideas?