The instance of entity type '' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked
Hi I am using Abp Framework with .net 7 and I have this service that has one to many relationship
in the dto of the entity i have list and when I send rquest from swagger to this sevice i get this error
The instance of entity type 'B' 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 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.
This is my model
`
public class A: AuditedAggregateRoot
{
public required string Name { get; set; }
public virtual ICollection Bs{ get; set; } = new List();
}
public class TaxAddressIdentity : AuditedAggregateRoot
{
public required string Phone { get; set; }
public required Guid AId { get; set; }
public virtual A A { get; set; }
}
`
And this is my dto
`public class CreateUpdateADto: EntityDto
{
public string Name { get; set; }
public ICollection Bs{ get; set; }
}`
And this is the service
`public interface IAAppService :
ICrudAppService<
ADto,
Guid,
AGetListInput,
CreateUpdateADto,
CreateUpdateADto>
{
}
public class AAppService : CrudAppService,
IAAppService
{
}`
And this is the mapping i am using in side the file ProjectNameApplicationAutoMapperProfile
CreateMap();
CreateMap(MemberList.Source);
can you give me any hekp please? i try every thing but still git the same error
0 comments:
Post a Comment
Thanks