我正在使用:
似乎我的配置文件没有被加载,每次我调用mapper.map我得到AutoMapper.AutoMapperMappingException:'缺少类型映射配置或不支持的映射.
这是我的Startup.cs类的ConfigureServices方法
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
//register automapper
services.AddAutoMapper();
.
.
}
Run Code Online (Sandbox Code Playgroud)
在另一个名为xxxMappings的项目中,我有我的映射配置文件.示例类
public class StatusMappingProfile : Profile
{
public StatusMappingProfile()
{
CreateMap<Status, StatusDTO>()
.ForMember(t => t.Id, s => s.MapFrom(d => d.Id))
.ForMember(t => t.Title, s => s.MapFrom(d => d.Name))
.ForMember(t => t.Color, s => s.MapFrom(d => d.Color));
}
public override string ProfileName
{
get …Run Code Online (Sandbox Code Playgroud)