Skip to content

ProjectTo NullReferenceException #3919

@kvpt

Description

@kvpt

Hi,

I tried to upgrade AutoMapper from version 10 to 11 and after that my tests failed with NullReferenceException from AutoMapper.

I identified that the issue is caused by the global mapping that I use to convert Null string to Empty string. This method did work up to version 10.
Standard mapping is not impacted but some ProjectTo now fail.

Source/destination types

See LinqPad reproduction in attachment.

Mapping configuration

See LinqPad reproduction in attachment.

Version: 11.0.1

AutoMapper version: either 11.0.0 or 11.0.1 (10.x version are not impacted)
EFcore version : either 5.x or 6.x (not Efcore dependant)

Expected behavior

The ProjectTo method work without issue.

Actual behavior

The ProjectTo method throw an NullReferenceException.

Steps to reproduce

LinqPad reproduction in attachment, drop it to LinqPad to execute.

ProjectToIssue.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions