Meh*_*lal 27 automapper asp.net-core .net-6.0
如何在 ASP.Net Core 6 中配置 AutoMapper
我有一个用 .Net 3.1 编写的项目,所以我们有 Startup.cs 类。
我正在将其迁移到 .net core 6
现在,当我将以下配置放入我的 .Net 6 Program.cs 中时
builder.Services.AddAutoMapper(typeof(Startup));
Run Code Online (Sandbox Code Playgroud)
我收到错误:无法找到类型或命名空间启动
有什么建议吗?我该如何修复它或在 .net 6 中配置它
小智 43
安装包
在程序.cs中
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
Run Code Online (Sandbox Code Playgroud)
创建MappingProfiles.cs
namespace XXX.XXX.Helpers;
public class MappingProfiles: Profile {
public MappingProfiles() {
CreateMap<Address, AddressDto>();
}
}
Run Code Online (Sandbox Code Playgroud)
Tin*_*ang 27
使用这一行代替:typeof(Program).Assembly
| 归档时间: |
|
| 查看次数: |
48403 次 |
| 最近记录: |