Hi I am implementing automapper in my c# mvc project i am following this tutorial
https://www.c-sharpcorner.com/article/web-api-crud-operations-and-consume-service-in-asp-net-mvc-application/
but i am getting error as shown below i have check my entiry model and model class my columns are same
"Getting this error on foreach loop Missing type map configuration or unsupported mapping. Mapping types: Product -> Product DataAccessLayer.Product -> API.Models.Product Destination path: Product Source value: DataAccessLayer.Product"
below are my classes
- public class EntityMapper<TSource, TDestination> where TSource : class where TDestination : class
- {
- public EntityMapper()
- {
- Mapper.CreateMap<Models.Product, Product>();
- Mapper.CreateMap<Product, Models.Product>();
- }
- public TDestination Translate(TSource obj)
- {
- return Mapper.Map<TDestination>(obj);
- }
- }
- public partial class Product
- {
- public int ProductId { get; set; }
- public string ProductName { get; set; }
- public Nullable<int> Quantity { get; set; }
- public Nullable<int> Price { get; set; }
- }
- public int ProductId { get; set; }
- public string ProductName { get; set; }
- public Nullable<int> Quantity { get; set; }
- public Nullable<int> Price { get; set; }
I am getting error on this line
- foreach (var item in prodList)
- {
- products.Add(mapObj.Translate(item));
- }
exception is Missing type map configuration or unsupported mapping.