Automapper问题:在版本升级和.NET升级后发现未映射的成员。

huangapple go评论61阅读模式
英文:

Automapper issue: Unmapped members were found after version upgrade and .Net Upgrade

问题

我正在升级 .Net Core 版本到 .Net 6.0,同时我也将相关的包,包括 Automapper 从版本 9.0 升级到 12.0。

但是在升级后,当我运行应用程序时,出现以下错误:

> 找到了未映射的成员。请查看下面的类型和成员。
> 添加自定义映射表达式、忽略、添加自定义解析器或修改源/目标类型...

之前一切都正常运行。

到目前为止我尝试过的事情:
我尝试在源和目标中都添加属性,就像我在异常消息中看到的那样,但它只是不断地将我带回循环,我不断地添加越来越多的属性,因为属性是相互依赖的。

请帮我解决这个问题,提供一个简单的方法,可以节省时间和精力,也可以是一个快速聪明的解决方案。

谢谢

英文:

I am upgrading the .Net Core Version to .Net 6.0 and while doing the same I upgraded the relevant packages including Automapper from ver 9.0 to 12.0.

But after upgrading when I run the application I get following error:

> Unmapped members were found. Review the types and members below.
> Add a custom mapping expression, ignore, add a custom resolver or modify the source/destination type...

Earlier it was all working fine.
Things I have tried so far:
I tried to add the properties in both source and destination, as I got in exception message but it just keeps looping me around and I keep adding more and more properties as properties are interdependent.

Please help me with this issue with something simple which can save both time and effort and can be a quick smart solution.

Thanks

答案1

得分: 1

通常,我会使用 AssertConfigurationIsValid 进行单元测试来测试我的配置 - 这可以为您提供更多信息。

https://docs.automapper.org/en/stable/Configuration-validation.html?highlight=AssertConfigurationIsValid%20

英文:

I usually have a unit test to test my configuration using AssertConfigurationIsValid - that can give you more information.

https://docs.automapper.org/en/stable/Configuration-validation.html?highlight=AssertConfigurationIsValid%20

huangapple
  • 本文由 发表于 2023年2月6日 16:02:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75358692.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定