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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:19:12+00:00 2026-06-11T15:19:12+00:00

I’ve been digging into ASP.net MVC for a little while now. It seems that

  • 0

I’ve been digging into ASP.net MVC for a little while now. It seems that most blogs and posts indicate that a “best practice” is to abstract away the Entity Framework by implementing the Repository Pattern. It also seems the recommended practice is to utilize View-Specific models instead of working directly with the EF Domain Entities.

It makes some sense because you can than implement a transparent layer of Caching in the Repository, your MVC app doesn’t need to know anything about Entity Framework, and the View-Specific POCO models don’t have all the EF methods and properties attached to them (which tend to mess up XML and JSON serialization).

But if that is the way people “should be” developing, why are all the Controller/View wizards and tooling in Visual Studio focused directly on Entity Framework? Why do all the Microsoft examples on http://www.asp.net/mvc seem to work directly with the framework and domain entities instead of creating repositories with caching and utilizing view specific models?

Also, if I should be using view-specific models, am I mapping the domain entities onto those models in the controller? Isn’t it inefficient to be returning an object graph to the controller if I only need certain fields? Or should I be creating view-model specific methods on my repository?

  • 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-11T15:19:13+00:00Added an answer on June 11, 2026 at 3:19 pm

    Why do all the Microsoft examples on http://www.asp.net/mvc seem to
    work directly with the framework and domain entities instead of
    creating repositories with caching and utilizing view specific models?

    Unfortunately I cannot answer this question as I am not a Microsoft employee working on the Visual Studio team creating those wizards nor publishing content on the http://asp.net/mvc site. Personally I am allergic to 99% of the wizards in Visual Studio and never touch them.

    Also, if I should be using view-specific models, am I mapping the
    domain entities onto those models in the controller?

    Yes. Alternatively you could use AutoMapper to simplify this process and unclutter your controller actions.

    Isn’t it inefficient to be returning an object graph to the controller
    if I only need certain fields?

    No, it is efficient. As a matter of fact it’s even faster (in terms of performance) than if you were mapping to a view model. It’s just that in most cases your domain models are not adapted to the requirements of your views. And from that moment the nightmare will start inside your views which will turn into spaghetti code in attempts to adapt those domain models – your views become now inefficient and not easily maintainable. You will quickly realize that the domain models do not contain all the necessary information the view needs. And what happens next? You start using another concept I am allergic to – ViewBag. So you are passing certain things to the view under the form of a strongly typed model, other things under the form of a weakly typed structures, things get messy. Also controller actions taking domain models instead of view models are vulnerable to mass injection attacks and you might be having troubles with things like validation.

    Or should I be creating view-model specific methods on my repository?

    Absolutely not. A repository works only with domain models. It doesn’t know what a view model is.

    Of course all those are my 2¢. Feel absolutely free to ignore them and work directly with your EF domain models inside your views if this is the pattern that suits you better and you feel more comfortable with. It would be incorrect trying to impose one or another pattern. Just use the one you feel right for your needs.

    • 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
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this

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.