使用AutoMapper做对象映射时,报“Missing type map configuration or unsupported mapping.”类型错误
使用AutoMapper做对象映射时,报“Missing type map configuration or unsupported mapping.”
-
配置文件添加以下内容:
startup.cs 文件中添加以下:
通过AppDomain.CurrentDomain.GetAssemblies()扫描配置文件。
实际上发现并没有对MobanProfile配置文件进行扫描,导致报以下错误: -
解决方法:
改为以下services.AddAutoMapper(typeof(MobanProfile).Assembly);
问题解决。
参考:https://q.cnblogs.com/q/125627/