且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ASP.NET MVC中配置AutoMapper属性

更新时间:2023-02-10 08:40:41

我将在Controller中(最终在构造函数中)进行操作:

I would do in the Controller (eventually in the constructor):

 typeof(RoleViewModel).Assembly.MapTypes();

如果安装Automapper的版本4,则可以解决此问题,因为在最后一个版本中,属性不起作用.因此,请在Package-Manager控制台中添加以下说明:

The problem can be solved if you install version 4 of Automapper because in the last version Attributes are not working. So please add the following instructions in Package-Manager Console:

uninstall-package Automapper

install-package Automapper -version 4.2.1