Skip to content

Commit 4abcb3c

Browse files
committed
fix: ensuring entity is not already tracked when attaching
1 parent ed2b2d9 commit 4abcb3c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ private void AttachHasManyThrough(TEntity entity, HasManyThroughAttribute hasMan
250250

251251
foreach (var pointer in pointers)
252252
{
253-
_context.Entry(pointer).State = EntityState.Unchanged;
253+
if (_context.EntityIsTracked(pointer as IIdentifiable) == false)
254+
_context.Entry(pointer).State = EntityState.Unchanged;
254255
var throughInstance = Activator.CreateInstance(hasManyThrough.ThroughType);
255256

256257
hasManyThrough.LeftProperty.SetValue(throughInstance, entity);

0 commit comments

Comments
 (0)