C#
C#

help

Root Question Message

Oops365
Oops3658/19/2022
AutoMapper.Collection.EFCore

Hey, I'm having trouble saving a nested collection using AutoMapper.Collection.EFCore. Specifically when I try to add a new item to a list, I get the exception below.
InnerException: ' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.


var parent = await _context.Parents.Include(p => p.ChildrenArray).FirstAsync(p => p.Sub == request.Sub);

// one of the nested properties is a List
_mapper.Map(request, parent);

// error here
await _context.SaveChangesAsync();
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy