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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:33:14+00:00 2026-06-09T13:33:14+00:00

I am new to MVC and new to using EF. In our application we

  • 0

I am new to MVC and new to using EF. In our application we are using Database first approach. As we are using DB first approach, we are geneting edmx from the db.

When I generate the edmx, it generates all the related classed for the tables in my database. Here only I am confusing a lot whether to use the generated classed in my views directly or should I create one more layer of classes on top of the EF generated classed and use them from my controllers and views.

If I am creating one more layer of classes on top of entities I have to take care of mapping in betweeb these classes. I doubt that could be a pain in the future if there is any change in the model.

If I am directly using the entities from my controllers, I feel I am exposing all the unnecessary things to the controllers and views.

Can somebody please advise me how to proceed on 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-06-09T13:33:16+00:00Added an answer on June 9, 2026 at 1:33 pm

    You are doing it fine just how you have it, you don’t need to change it. You should be able to use the generated classes or if you think you are exposing too much, you can make a view model that you will populate with just the data you care about and pass that to the view. This is how MVC is supposed to work.

    Say you have a database table called Articles and there is a lot of stuff in there that you don’t wan’t to pass to the view, you could create a view model like this

    public class ArticlesViewModel
    {
        [Required] // this is optional, just to give you an idea of validation
        public string Title { get; set; }
        public DataTime Date { get; set; }
    }
    

    Now in your controller you would have something like this:

    ArticlesViewModel articleVM = new ArticlesViewModel();
    // populate it from your DB
    
    return View(articleVM);
    

    So now your view only has the Title and Date, (you should also have ID so you can retrieve the full Article from the DB easily.)

    This will give you an idea of just grabbing the needed info from your DB.

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

Sidebar

Related Questions

Planning to create a new website for our product using ASP.NET MVC 4. Site
I'm very new to MVC, and just building my first site, using NerdDinner as
We have written Web application using ASP.NET MVC, which will be hosted in our
We are using Spring MVC 3.0 in our web application. We are also using
I'm new to using MVC and I'm trying to make a model that uses
I'm new to MVC (I'm using codeigniter) and was wondering where I should put
I will start new project which is based on ASP.NET MVC 3 using C#
I'm planning to design simple website using ASP.NET MVC new technology. Many concepts are
I am using ASP MVC to develop a new project. I am using the
I'm using a Telerik MVC Splitter like this: @(Html.Telerik().Splitter().Name(MainSplitter) _ .Orientation(SplitterOrientation.Horizontal) _ .HtmlAttributes( New

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.