Entity Model
public partial class Categoies
{
public Categoies()
{
this.Posts = new HashSet();
}
public int Id { get; se
I found the solution, Thanks all for reply.
category = (Categoies)AutoMapper.Mapper.Map(viewModel, category, typeof(CategoriesViewModel), typeof(Categoies));
But, I have already dont know the reason. I cant understand fully.
Check your Global.asax.cs file and be sure that this line be there
AutoMapperConfig.Configure();
Upgrade Automapper to version 6.2.2. It helped me
I was trying to map an IEnumerable to an object. This is way I got this error. Maybe it helps.
I created a new AutomapperProfile class. It extends Profile. We have over 100 projects in our solution. Many projects have an AutomapperProfile class, but this one was new to this existing project. However, I did find what I had to do to fix this issue for us. There is a Binding project. Within the Initialization there is this code:
var mappingConfig = new List<Action<IConfiguration>>();
// Initialize the Automapper Configuration for all Known Assemblies
mappingConfig.AddRange( new List<Action<IConfiguration>>
{
ConfigureProfilesInAssemblyOfType<Application.Administration.AutomapperProfile>,
//...
I had to add ConfigureProfilesInAssemblyOfType<MyNewNamespace.AutomapperProfile>
Note that ConfigureProfilesInAssemblyOfType looks like this:
private static void ConfigureProfilesInAssemblyOfType<T>( IConfiguration configuration )
{
var log = LogProvider.Get( typeof (AutomapperConfiguration) );
// The Automapper Profile Type
var automapperProfileType = typeof (Profile);
// The Assembly containing the type
var assembly = typeof (T).Assembly;
log.Debug( "Scanning " + assembly.FullName );
// Configure any Profile classes found in the assembly containing the type.
assembly.GetTypes()
.Where( automapperProfileType.IsAssignableFrom ).ToList()
.ForEach( x =>
{
log.Debug( "Adding Profile '" + x.FullName + "'" );
configuration.AddProfile( Activator.CreateInstance( x ) as Profile );
} );
}
Best regards, -Jeff
In my case, I had created the map, but was missing the ReverseMap function. Adding it got rid of the error.
private static void RegisterServices(ContainerBuilder bldr)
{
var config = new MapperConfiguration(cfg =>
{
cfg.AddProfile(new CampMappingProfile());
});
...
}
public CampMappingProfile()
{
CreateMap<Talk, TalkModel>().ReverseMap();
...
}