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

  • SEARCH
  • Home
  • 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 8885805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:24:04+00:00 2026-06-14T21:24:04+00:00

I have quite a bit of entities and so far, I’ve been doing stuff

  • 0

I have quite a bit of entities and so far, I’ve been doing stuff like

Mapper.CreateMap<Employee, EmployeeDetailsDTO>()
    .ForSourceMember(mem => mem.NewsPosts, opt => opt.Ignore());

I want to tell AutoMapper to simply ignore missing properties in the destination object without having to specify each of them. So far, I haven’t found a way to do so with my multiple SO and Google searches. Anyone has a solution? I’m ready to do some sort of loop or anything, as long as it can be written once and that it will scale with model / dto changes or added properties.

  • 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-14T21:24:05+00:00Added an answer on June 14, 2026 at 9:24 pm

    When are you getting the error? Is it when you call AssertConfigurationIsValid ?

    If yes, then simply dont call this method

    You dont have to call this method, consider the following mapping which works:

    public class Foo1
    {
        public string Field1 { get; set; }
    }
    public class Foo2
    {
        public string Field1 { get; set; }
        public string Field2 { get; set; }
    }
    
    Mapper.CreateMap<Foo1, Foo2>();
    var foo1 = new Foo1() {Field1 = "field1"};
    var foo2 = new Foo2();
    Mapper.Map(foo1, foo2);//maps correctly, no Exception
    

    You may want to call AssertConfigurationIsValid for other mappings to ensure they are correct so instead what you need to do is organize your mappings into Profiles:

    public class MyMappedClassesProfile: Profile
    {
        protected override void Configure()
        {
            CreateMap<Foo1, Foo2>();
            //nb, make sure you call this.CreateMap and NOT Mapper.CreateMap
            //I made this mistake when migrating 'static' mappings to a Profile.    
        }
    }
    
    Mapper.AddProfile<MyMappedClassesProfile>();
    

    and then if you decide you want to check the validity of the mapping (case by case basis in your situation) then call

    Mapper.AssertConfigurationIsValid(typeof(MyMappedClassesProfile).FullName);
    

    important in your case and/or any case where you dont call AssertConfigurationIsValid you should use something like AutoFixture and a Unit Test to ensure your mapping is working. (which is the intent of AssertConfigurationIsValid)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My one activity seems to have grown quite a bit and I feel like
I have been searching for quite a bit now but I have never been
We have quite a bit of reusable code at work (a good thing). Whenever
When this callback is made in my app, I have quite a bit work
I'm making an engine/CMS for story-based web browser games. I have quite a bit
Have done quite a bit of searching for a guide (of any substance) for
Okay I have updated my code quite a bit. I am getting a new
I have a pre tag within my page that contains quite a bit of
I've done quite a bit of googling on this error but have had no
I've read around quite a bit but haven't found a definitive answer. I have

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.