我正在使用 NopCommerce 3.0 映射以下实体和模型
实体
public partial class Package : BaseEntity
{
public int ProductID { get; set; }
public int Quantity { get; set; }
public int PackageNumber { get; set; }
public string Weight { get; set; }
public int DisplayOrder { get; set; }
public bool Published { get; set; }
}
模型
[Validator(typeof(PackageValidator))]
public class PackageModel
{
[NopResourceDisplayName("Admin.Catalog.Packages.Fields.ProductID")]
public int ProductID { get; set; }
[NopResourceDisplayName("Admin.Catalog.Packages.Fields.Quantity")]
public int Quantity { get; set; }
[NopResourceDisplayName("Admin.Catalog.Packages.Fields.PackageNumber")]
public int PackageNumber { get; set; }
[NopResourceDisplayName("Admin.Catalog.Packages.Fields.Weight")]
//[AllowHtml]
public string Weight { get; set; }
[NopResourceDisplayName("Admin.Catalog.Packages.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
[NopResourceDisplayName("Admin.Catalog.Packages.Fields.Published")]
public bool Published { get; set; }
}
这是我的映射器类
public partial class PackageMap : EntityTypeConfiguration<Package>
{
public PackageMap()
{
this.ToTable("Package");
this.HasKey(m => m.Id);
this.Property(m => m.ProductID);
this.Property(m => m.Quantity);
this.Property(m => m.PackageNumber);
this.Property(m => m.Weight);
this.Property(m => m.DisplayOrder);
this.Property(m => m.Published);
}
}
但我收到以下异常
[AutoMapperMappingException:尝试将 Nop.Core.Domain.Catalog.Package 映射到 Nop.Admin.Models.Catalog.PackageModel。缺少类型映射配置或不支持的映射。引发了“AutoMapper.AutoMapperMappingException”类型的异常。] AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context) +382
我是 Asp.net MVC 的新手。请帮我。提前致谢 :)