I cannot reproduce this issue. Consider the following code:
using AutoMapper;
using Microsoft.Extensions.Logging;
namespace ConsoleApp1;
static class Program
{
static void Main()
{
var loggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(); });
var config = new MapperConfiguration(cfg =>
cfg.CreateMap<Source, Destination>()
.ForMember(dest => dest.Y, opt => opt.MapFrom(src => src.C))
.ForMember(dest => dest.B, opt => opt.Ignore()),
loggerFactory
);
var s = new Source { A = 1, B = 2, C = 3 };
var m = config.CreateMapper();
var d = m.Map<Destination>(s);
Console.WriteLine($"A={d.A}, B={d.B}, Y={d.Y}");
}
}
public sealed class Source
{
public int A { get; set; } // Same as Destination
public int B { get; set; } // Should not be mapped
public int C { get; set; } // Should be mapped to Destination.Y
}
public sealed class Destination
{
public int A { get; set; } // Same as Source
public int B { get; set; } // Should not be mapped
public int Y { get; set; } // Should be mapped from Source.C
}
The output from this is:
A=1, B=0, Y=3
Which shows that A was mapped from Source.A to Destination.A, Y was mapped from Source.C to Destination.Y and Source.B was not mapped to Destination.B.
NOTE: This was using Automapper version 15.0.0.
[Offtopic: Personally I'd use Mapster (which is free) rather than AutoMapper (which is now commercial)]