在我的Startup.cs
文件中,我的ConfigureServices
方法中有一个AutoMapper配置:
AutoMapper.Mapper.Initialize(c => c.AddMaps(typeof(Models.MapperProfile), typeof(Data.Ef.MapperProfile)));
namespace Rm.Combo.Api.Models
{
public class MapperProfile : Profile
{
public MapperProfile()
{
CreateMap<NewCashoutModel, App.Cashouts.InitiateCashoutCommand>();
}
}
}
namespace Rm.Combo.Data.Ef
{
public class MapperProfile : Profile
{
public MapperProfile()
{
CreateMap<Domain.Cashouts.Cashout, Data.Cashouts.CashoutModel>();
}
}
}
自从我从版本8.1.1
迁移到9.0.0
以来,似乎有一些重大更改。
我试图检查那些特定的链接:
但是他们都没有说如何
从9.0开始,静态API不再可用。
您可以通过依赖注入使用AutoMapper,如下所示:
1。安装AutoMapper.Extensions.Microsoft.DependencyInjection
2。在Startup.cs的AutoMapper.Extensions.Microsoft.DependencyInjection
中注册服务:
ConfigureServices
参考:services.AddAutoMapper(typeof(MapperProfile));