#4657·AutoMapper

Registration order causes `ResolutionContext.OverTypeDepth` to access `Context.Items` in AutoMapper 16.2.0

Author: rdeeptoolsCreated Sep 19, 2026Updated Sep 19, 2026

Versions

  • AutoMapper 16.2.0
  • .NET 10.0
  • The issue was encountered while upgrading an application from AutoMapper 13.0.1 to 16.2.0.

Description

After upgrading from AutoMapper 13.0.1, mapping a recursive object graph with AutoMapper 16.2.0 started throwing an exception from ResolutionContext.OverTypeDepth.

The behavior depends only on type-map registration order. In the attached console application, registering the containing InitiativeEntity -> InitiativeModel map before EpicEntity -> EpicModel causes the failure. Swapping those two adjacent registrations makes the same mapping succeed.

The mapped source is an EpicEntity with populated Stories and WorkItems. The nested graph contains a WorkItemEntity -> EstimateEntity -> WorkItemEntity back-reference.

Reproduction

Run:

powershell
dotnet run

The application directly calls:

csharp
mapper.Map<EpicModel>(epic);

No mapping-operation options are used.

Actual behavior

AutoMapperMappingException: Error mapping types.
Destination Member: Stories
 ---> System.InvalidOperationException:
Context.Items are only available when using a Map overload that takes
Action<IMappingOperationOptions>! Consider using Context.TryGetItems instead.
   at AutoMapper.ResolutionContext.OverTypeDepth(TypeMap typeMap)

Application code does not access Context.Items.

Expected behavior

Mapping should not depend on the order in which the two type maps are registered. The ordinary Map<TDestination>(source) overload should succeed without requiring mapping-operation options.

Workaround demonstrated by the reproduction

Register EpicEntity -> EpicModel before InitiativeEntity -> InitiativeModel.

Example

AutoMapper16RecursiveGraphInvestigation.zip

Source: LuckyPennySoftware/AutoMapper