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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:17:18+00:00 2026-05-20T06:17:18+00:00

I have been working on a new MVC application that utilizies EF4, POCO Domain

  • 0

I have been working on a new MVC application that utilizies EF4, POCO Domain Objects and the Repository <–> Service Layer.

I see a lot of talk about using AutoMapper to map the EF4 classes to the DTO for the View Models. I was under the impression that this was to get rid of the tightly bound EF4 classes. So my question is since I am using the POCO classes, can’t I just use those in the View Models? Or is there still a need for AutoMapper?

  • 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-20T06:17:19+00:00Added an answer on May 20, 2026 at 6:17 am

    The argument is that your “POCO’s” are your domain models, and your View’s shouldn’t be concerned with Domain Models.

    Think about it this way – data validation, if you want data annotations, you would have to put them on your POCO’s – but input validation (this field is required, etc) isn’t really a domain concern, it’s a UI concern – hence the use of ViewModels for Data Annotations and AutoMapper.

    Of course, it’s not cut and dry, it’s a matter of preference.

    I also use MVC/EF4/POCO/AutoMapper/Service Layer and i never bind to the POCO’s – i always use a ViewModel per View.

    This way, you have a good level of consistency:

    • All View’s have a ViewModel
    • POCO’s have nothing but business/domain logic
    • ViewModel’s have basic input validation
    • They are then mapped to the POCO’s, which invoke domain/business validation

    **Edit – in response to comments: **

    Do your Repositories return IQueryable? If so, how do you handle the context? I mean does your Repositories implement IDisposable and then you dispose of them in the controllers?

    Yes – my Repositories return IQueryable<T>, where T is an aggregate root. My Repositories get passed a Unit of Work (which implements IDisposable). The Unit of Work is a wrapper for the EF4 context. StructureMap (DI container) is responsible for the lifetime of the components (including the UoW – aka the context). I new up a UoW per HTTP request and Dispose when it’s finished. My “Service” calls methods on my IQueryable repository and returns collections (e.g materializes the query before being passed back to the Controller).

    Where do you do your mapping at? Do you do it in the controller?

    Up to you. Personally, i would create a static “bootstrapper” class that has a single method, e.g “Configure”. Call this once in your Application_Start event (Global.asax). This technique is decribed here.

    Good luck!

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

Sidebar

Related Questions

I have a new MVC 2 site that has been working fine on my
I have been working on test framework, which creates a new app domain to
Here's my situation: I have been working on an ASP.NET MVC 3 application for
i have been working on a new .net MVC site and have integrated some
I have an existing ASP.NET MVC 2 application that I've been asked to extend.
I have an MVC app that I have been working on but I seem
I have been working with an MVC app and creating Repositories that manipulate, validate,
I have to admit in advance that I'm quite new to MVC, I've been
Alright have been working to switch to jQuery 1.7's new and improved .on() function
I have been working on Eclipse recently. I am fairly new to java programming,

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.