I use Automapper with CreateMissingTypeMaps option set to true. If I try to fill an existing object of the same type, it doesn't work.
class A
{
public string X { get; set; }
}
var config = new MapperConfiguration(cfg => cfg.CreateMissingTypeMaps = true);
var mapper = config.CreateMapper();
var a1 = new A { X = "sample" };
var a2 = new A();
mapper.Map(a1, a2); // a2.X was not set
If I create a new object of the same type, it works fine
var a3 = mapper.Map<A>(a1); // a3.X is set
If I fill an existing object of a different type, it also works
class B
{
public string X { get; set; }
}
var b = new B();
mapper.Map(a1, b); // b.X is set
But if I try to fill an existing object of the same type, it doesn't. Is it a bug in Automapper or am I missing something?