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 7129039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:12:04+00:00 2026-05-28T11:12:04+00:00

I’ve been using AutoMapper for a few months now with success but now I’ve

  • 0

I’ve been using AutoMapper for a few months now with success but now I’ve hit a bit of a stumbling block. What I need (or think I need) is for 2 way mapping. This is for when I load an item from the database to play on the screen (domain object -> view model) and when the users make changes to said item and map it back to my domain object (view model -> domain object).

I understand that I could simply create a mapping in my profile to handle the two-way mapping but I was reading here that two-way mapping are unnecessary. Many people indicate that doing so is a response to not fixing the bigger issue (what ever that may be).

I’m just wondering why is this a code smell?

  • 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-05-28T11:12:04+00:00Added an answer on May 28, 2026 at 11:12 am

    When I was a junior dev, I worked on a large project which basically did what you are describing. We didn’t use automapper, but we created viewmodels which encapsulated domain objects which basically meant that you got your changes from the view directly to the domain objects. Just persist your changes and presto they are where you want them to be (in the database). That application should have released four years ago, but they are still struggling.

    Why is this a smell? Well you are losing track of any intent as to why you are changing stuff. And intent is something that is really really important as your application grows and becomes more complex. Its difficult to enforce new rules into you domain because it is difficult to see exactly which operations are valid to perform on your domain. If you make your domain model auto-mappable, its also very anemic.

    As Jimmy points out, you want to model your domain after the requirements of your domain, not to the requirements of automapper. If automapper were to work directly on your model you would have to make adjustments like making property-setters public, although that might not be a good idea from a domain-modeling perspective.

    I think the bigger issue is that a domain model which can be automapped directly from viewmodels does not convey intent, nor encapsulation in a satisfying manner. If you are creating a small app, then active record/dataset style architecture might not be a bad thing, but if the solution is larged scaled or complex you have bigger issues than mapping from viewmodel to domain.

    In the current application I am working on, we use automapper to map from domain to dto’s and from dto’s to viewmodels. When something is to be persisted we translate the operation on the viewmodels into explicit commands which are executed against the domain. I’ve would never ever recommend a three layered architecture in any large scale app (thin or thick client).

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I need to clean up various Word 'smart' characters in user input, including but
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.