You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
###Background
Record was previously a class and I changed it to a record. For my test to work I had to use the with syntax when calling the UpdatedRecord method. This failed in my test and also when trying this against the running application using SqlServer.
I found this line in IdentityMap.cs which ends up throwing the exception...
System.InvalidOperationException
The instance of entity type 'TimeOffRequest' cannot be tracked because another instance with the same key value for {'Key'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap`1.ThrowIdentityConflict(InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap`1.Add(TKey key, InternalEntityEntry entry, Boolean updateDuplicate)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap`1.Add(TKey key, InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap`1.Add(InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges, Boolean modifyProperties)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState entityState, Boolean acceptChanges, Boolean modifyProperties, Nullable`1 forceStateWhenUnknownKey)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction(EntityEntryGraphNode`1 node)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph[TState](EntityEntryGraphNode`1 node, Func`2 handleNode)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph(InternalEntityEntry rootEntry, EntityState targetState, EntityState storeGeneratedWithKeySetTargetState, Boolean forceStateWhenUnknownKey)
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.SetEntityState(InternalEntityEntry entry, EntityState entityState)
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.Update(TEntity entity)
provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.SqlServer 5.0.0
Test Database provider: Microsoft.EntityFrameworkCore.Sqlite 5.0.0
Target framework: .NET 5.0
Operating system: Windows 10/WSL Ubuntu
IDE: Rider
The text was updated successfully, but these errors were encountered:
###Background
Record was previously a class and I changed it to a record. For my test to work I had to use the
with
syntax when calling theUpdatedRecord
method. This failed in my test and also when trying this against the running application using SqlServer.I found this line in IdentityMap.cs which ends up throwing the exception...
Code
Stack trace
provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.SqlServer 5.0.0
Test Database provider: Microsoft.EntityFrameworkCore.Sqlite 5.0.0
Target framework: .NET 5.0
Operating system: Windows 10/WSL Ubuntu
IDE: Rider
The text was updated successfully, but these errors were encountered: