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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:15:02+00:00 2026-05-17T19:15:02+00:00

I wanted to compare with best practices when working with an ORM or database

  • 0

I wanted to compare with best practices when working with an ORM or database tables in asp.net mvc. One of the major questions I have is should I instantiate the model classes directly in controller..not query the database but just use the model class to store the values.

For e.g. If I am using entity framework as model…then is it a bad practice to use the entity class objects in the controller. There are times when it is just easier to directly use the database classes generated in the controller instead of creating ViewModels or even ViewData. We have a data access layer and a Business layer where all the querying and business logic is applied but although easier I don’t like the idea of accessing the model in the controller but is it really a bad practice?

  • 1 1 Answer
  • 2 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-17T19:15:03+00:00Added an answer on May 17, 2026 at 7:15 pm

    Yes, it is a bad practice, because of the problem of “over-posting”.

    For instance, consider an Entity model for a UserProfile:

      public class UserProfile
      {
        public string UserName { get; set; }
        public bool IsAdmin { get; set; }
        public string EmailAddress { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
      }
    

    Your user profile page allows the user to Edit their FirstName, LastName, and EmailAddress.

    An unscrupulous user could simply modify the form to post “IsAdmin” along with the other values. Because your Action is expecting an input of UserProfile, the IsAdmin value will be mapped as well, and eventually persisted.

    Here is an excellent writeup about the perils of under and overposting.

    I see nothing wrong with binding Entity models directly to your [HttpGet] methods, though.

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

Sidebar

Related Questions

I wanted to compare 2 XMLs, which have the same data but the tag
Lets say i wanted to compare a variable in the sqlite database and if
I wanted to compare the performance characteristics of immutable.Map and mutable.Map in Scala for
I just wanted to compare a double number saved in a double variable in
Out of curiosity I wanted to test the number of ticks to compare a
hi I wanted to have some keys and values filtered out when compared with
Wanted to know if there was a way one could query shelveset details from
I have a list of dicts and I want to compare each dict in
So I wanted to compare the performance of python between 2.6 and 3.1, so
I have some legacy code that uses Interlocked.Equals to compare values. The values may

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.