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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:44:10+00:00 2026-05-23T14:44:10+00:00

So I have this two classes: public class PhysicalTest { public int ID {

  • 0

So I have this two classes:

public class PhysicalTest
    {
        public int ID { get; set; }       
        public DateTime CreationDate { get; set; }
        public int Weight { get; set; }
        public int Height { get; set; }
        public int Systolic { get; set; }  
        public int Diastolic { get; set; } 
        public int Pulse { get; set; }
}

public class PhysicalTestFormViewModel
    {
        public int ID { get; set; }       
        public DateTime CreationDate { get; set; }
        [Required]
        public int Weight { get; set; }
        [Required]
        public int Height { get; set; }
        public int Systolic { get; set; }  
        public int Diastolic { get; set; } 
        public int Pulse { get; set; }
}

This is my AutoMapper configuration

Mapper.CreateMap<PhysicalTestFormViewModel, PhysicalTest>();

When I do this it works just fine

 [HttpPost]
        public ActionResult Create(int ehrId, PhysicalTestFormViewModel physicaltestvm)
        {
            EHR ehr = ehrRepository.Find(ehrId);
            if (ehr.UserName != User.Identity.Name)
                return View("Invalid Owner");

            if (ModelState.IsValid)
            {
                PhysicalTest physicalTest= new PhysicalTest();
                Mapper.Map(physicaltestvm, physicalTest);
                physicalTest.PerformedBy = "Yo";
                physicalTest.CreationDate = DateTime.Now;
                ehr.PhysicalTests.Add(physicalTest);
                ehrRepository.Save();
                return RedirectToAction("Index");
            }
            else
            {
                return View(physicaltestvm);
            }
        }

But when I do this I get an error

Trying to map Summumnet.PhysicalTest
to
Summumnet.ViewModels.PhysicalTestFormViewModel.
Missing type map configuration or
unsupported mapping. Exception of type
‘AutoMapper.AutoMapperMappingException’
was thrown.

public ActionResult Edit(int ehrId, int id)
        {
            EHR ehr = ehrRepository.Find(ehrId);
            if (ehr.UserName != User.Identity.Name)
                return View("Invalid Owner");
            var physicalTest = ehr.PhysicalTests.Where(test => test.ID == id).Single();
            PhysicalTestFormViewModel physicaltestvm = new PhysicalTestFormViewModel(); 
            Mapper.Map(physicalTest, physicaltestvm); 
            return View(physicaltestvm);
        }

In the scenario where the error is thrown I simply want to construct an ViewModel to display an Edit form…. what is the standard way of doing this?

  • 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-23T14:44:11+00:00Added an answer on May 23, 2026 at 2:44 pm

    You have only defined a mapping from PhysicalTestFormViewModel to PhysicalTest:

    Mapper.CreateMap<PhysicalTestFormViewModel, PhysicalTest>();
    

    You also need the opposite one:

    Mapper.CreateMap<PhysicalTest, PhysicalTestFormViewModel>();
    

    See this related SO question and answers.

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

Sidebar

Related Questions

I have two classes public class A { public int BaseA {get;set;} } public
I have two classes public class JobDataProvider { public List<Job> Get(int id){ List<Job> jobs
I have two classes: public class RichMan { public string ID {get;set;} List<Car> _cars=new
I have this weird situation. I have these two classes: Public Class Entry End
I have two classes: public class Parent { public virtual long? ID { get;
I have a two classes: public class Question { public IList<Answer> Answers { get;
I have two classes: public class DocumentViewModel { public virtual string DocumentNumber { get;
I have two classes: public class Person { public string FirstName { get {
This is for a playbook app. I have two classes: public dynamic class Bullet
Let's say I have two classes that look like this: public class ByteFilter {

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.