Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:53:33+00:00 2026-06-15T22:53:33+00:00

I am having an issue where automapper is trying to map a property that

  • 0

I am having an issue where automapper is trying to map a property that I do not want it to map. I can fix this issue by renaming the property to something else but I want to use the name and I want to know how to fix issues like this.

My code looks like this.

public abstract class Task
    {
        public int Id { get; set; }
        public int ProjectId { get; set; }
        public virtual Project Project { get; set; }
        public string Title { get; set; }
    }

 public class BasicTask : Task
    {
    }
public abstract class Project
    {

        public virtual int Id { get; set; }
        public virtual string Title { get; set; }
        public virtual ICollection<Task> Tasks { get; set; }
        [NotMapped]
        public abstract string ProjectTypeDescription { get; }

    }
public class BasicProject : Project
    {
        public override string ProjectTypeDescription
        {
            get { return "Basic Project"; }
        }
    }


public abstract class TaskViewModel
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public abstract string TaskType { get; }
        //This is the property giving me issues
        public ProjectDetails Project { get; set; }

        public class ProjectDetails
        {
            public int Id { get; set; }
            public string Title { get; set; }
        }
    }
public class BasicTaskViewModel : TaskViewModel
    {
        public override string TaskType
        {
            get { return "Basic"; }
        }
    }
public abstract class ProjectViewModel
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public SelectList ProjectTypes { get; set; }
        public abstract string ProjectType { get; }
        public IEnumerable<TaskViewModel> Tasks { get; set; }
    }
public class BasicProjectViewModel : ProjectViewModel
    {
        public override string ProjectType
        {
            get { return "Basic Project"; }
        }
    }

My mapping for Tasks looks like (I removed the project mapping since I can replicate the problem without those mappings)

Mapper.CreateMap<Task, TaskViewModel>()
                .ForMember(dest => dest.Project, opt => opt.Ignore())
                .Include<BasicTask, BasicTaskViewModel>();
            Mapper.CreateMap<BasicTask, BasicTaskViewModel>();

            Mapper.CreateMap<TaskViewModel, Task>()
                .Include<BasicTaskViewModel, BasicTask>();
            Mapper.CreateMap<BasicTaskViewModel, BasicTask>();

            Mapper.CreateMap<Project, TaskViewModel.ProjectDetails>();

I am use an extenstion method for the mapping

public static TResult MapTo<TResult>(this object self)
        {
            return (TResult)Mapper.Map(self, self.GetType(), typeof(TResult));
        }

An example of using this that fails is

TaskViewModel vm = new BasicTaskViewModel()
            {
                Id = 1,
                Project = new TaskViewModel.ProjectDetails()
                {
                    Id = 1,
                    Title = "Some Title",
                }
            };

            Task m = vm.MapTo<Task>();

Sorry for the very long post I just don’t know where the problem is.

If I rename Project in the taskviewmodel to something else it works and doesn’t map TaskViewModel.ProjectDetails to Project which is what I want.

I have tried adding ForSourceMember(src => src.Project, opt => opt.Ignore()) in every spot that I can

When I run this I get the follwoing

 Missing type map configuration or unsupported mapping.

Mapping types:
ProjectDetails -> Project
amtest.ViewModel.TaskViewModel+ProjectDetails -> amtest.Models.Project

Destination path:
BasicTask.Project.Project

Source value:
amtest.ViewModel.TaskViewModel+ProjectDetails
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types:
ProjectDetails -> Project
amtest.ViewModel.TaskViewModel+ProjectDetails -> amtest.Models.Project

Destination path:
BasicTask.Project.Project

Source value:
amtest.ViewModel.TaskViewModel+ProjectDetails
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:53:34+00:00Added an answer on June 15, 2026 at 10:53 pm

    Does it help when you add the ignore also to the mapping of the child class?

    Mapper.CreateMap<BasicTaskViewModel, BasicTask>()
          .ForMember(dest => dest.Project, opt => opt.Ignore());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue here that I have tried everything I can think of but
I having issue that content assistant / intellisense is working in methods such as
Hi guys I am having issue I have this query: SELECT * FROM useraccount
Having an issue with random individuals trying to access an intranet site with a
Having issue with prefetching data and displaying on uitableview. So basically I want to
I'm having issue converting this string to a decimal. I tried to follow the
I'm having issue with Action Listener of a JTable that being updated according the
I am having issue with a wordpress Tag CLoud Plugin. I want to show
We have a device that support SAE J1939 interface and having issue with finding
Having issue with my navigation. How can I prevent it? My CSS file looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.