For .net 9, fixed above by adding to program.cs builder.Services.AddAutoMapper(typeof(Program)); // Register AutoMapper