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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:39:14+00:00 2026-06-17T07:39:14+00:00

I’m thinking to develop a web / mobile application with MVC4. For what I

  • 0

I’m thinking to develop a web / mobile application with MVC4. For what I know about ASP.NET MVC, it works great when you have a 1 to 1 relationship between a table and a model class, while I had some problems when you need to work with normalized database.

—UPDATE—

Even if in the past I used Linq to SQL, I’m thinking to use Entity Data Model (not sure yet, but it seems better at the first glance).

—

A stupid example:

**table person**
ID
Name
Surname
HairColorID

**table hairColor**
HairColorID
Color

I wish to know if a situation like that can be easily solved in MVC4, without too much code writing in order to map manually all the table. I mean, I don’t know if there are some easy ways to have in my Controllers something like:

public ActionResult About(Person person)

where person automatically join my two tables.

  • 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-17T07:39:15+00:00Added an answer on June 17, 2026 at 7:39 am

    I break my application into several different layers using different projects.

    • My AppName.Data project handles all of my data access (i.e. retrieving data from the database).
    • My AppName.Models project houses all of the view model classes and
      other model classes that I will need for my app.
    • My AppName.Web project is simply the MVC web app
    • My AppName.Services project handles all of my business logic and communication between the web layer and the data layer. It builds the view models, handles data validation, etc. I never call a controller action method with an actual database object. I always use view models. That view model ONLY contains what I need to populate my view.

    So, in this instance, what I would do if this was a read-only view is create an AboutPersonDisplayViewModel that looks like the following:

    public class AboutPersonDisplayViewModel
    {
        public int PersonID { get; set; }
        public string Name { get; set; }
        public string Surname { get; set; }
        public string HairColor { get; set; }
    }
    

    And if it were an editable view, I would have a separate view model like this:

    public class AboutPersonEditViewModel
    {
        public int PersonID { get; set; }
        public string Name { get; set; }
        public string Surname { get; set; }
        public int HairColorID { get; set; }
        public IDictionary<int, string> HairColorOptions { get; set; }
    }
    

    In the database, you should have a relationship between the person and hairColor tables. So, when you build your view model, you simple get the person for the ID you want to look up and populate the AboutPersonViewModel with that person’s information and use the navigation properties to navigate to Person.HairColor to get the hair color for the ID stored.

    Then, when I save, the service layer would validate the data and properly map/save the hair color chosen.

    I hope this helps

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

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
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 have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I

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.