I have a model and ViewModel like this
public class Estate : BaseEntity
{
public virtual BaseInformation floorType { get; set; }
}
public class BaseInformation:BaseEntity
{
public string Name { get; set; }
public virtual BaseInformationHeader Master { get; set; }
}
public class EstateViewModel : BaseEntityViewModel
{
public long floorType { get; set; }
}
And the code in controller:
[HttpPost]
public long save(EstateViewModel estateViewModel)
{
Estate entity = new Estate();
BaseInformation bi = new BaseInformation();
bi.id = 1;
entity.floorType = bi;
EstateViewModel ev = new EstateViewModel();
Mapper.CreateMap<EstateViewModel, Estate>();
var model = AutoMapper.Mapper.Map<EstateViewModel,Estate>(estateViewModel);
return estateRepository.save(entity);
}
When the action is executed AutoMapper throws the following exception:
An exception of type 'AutoMapper.AutoMapperMappingException' occurred in AutoMapper.dll but was not handled in user code
What is causing this to happen?