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

  • Home
  • SEARCH
  • 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 796575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:39:44+00:00 2026-05-14T22:39:44+00:00

How can I share the auto-generated entity data model (generated object classes) amongst all

  • 0

How can I share the auto-generated entity data model (generated object classes) amongst all layers of my C# web app whilst only granting query access in the data layer? This uses the typical 3 layer approach: data, business, presentation.

My data layer returns an IEnumerable<T> to my business layer, but I cannot return type T to the presentation layer because I do not want the presentation layer to know of the existence of the data layer – which is where the entity framework auto-generated my classes.

It was recommended to have a seperate layer with just the data model, but I’m unsure how to seperate the data model from the query functionality the entity framework provides.

  • 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-14T22:39:44+00:00Added an answer on May 14, 2026 at 10:39 pm

    If you use POCO entities (.NET 4+), then this is easy (or at least easier). Is that a possibility?

    You can create DTOs as Ben said, but then you’re basically dumbing down and duplicating each of the entities. EF2 will create the “dumbed down” entities and dynamically add change tracking, lazy loading, etc. if you wish.

    Otherwise the answer is you can’t. If the entities depend on the Entity Framework, then you can’t use them throughout your application without dragging that dependency along. In that case you have to use DTOs. Here’s a 3rd party option for EF 1 or EF 2 without POCO entities.
    http://automapper.codeplex.com/

    Edit: Here are some useful links to learn more about all this:

    1. General MS guidelines:
      http://msdn.microsoft.com/en-us/library/bb738470.aspx
    2. POCO templates:
      http://blogs.msdn.com/adonet/pages/walkthrough-poco-template-for-the-entity-framework.aspx
    3. POCO templates, including how to
      move to separate project
      :
      http://blogs.msdn.com/adonet/pages/feature-ctp-walkthrough-poco-templates-for-the-entity-framework.aspx
    4. POCO proxies:
      http://blogs.msdn.com/adonet/archive/2009/12/22/poco-proxies-part-1.aspx
    5. How to split up model:
      http://blogs.msdn.com/adonet/archive/2008/11/25/working-with-large-models-in-entity-framework-part-2.aspx
    6. Employee Tracker sample application
      (layers, unit tests, mocking,
      repository, etc.):
      http://code.msdn.microsoft.com/ef4/Release/ProjectReleases.aspx?ReleaseId=4279
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I share/link App.config or Web.config between multiple projects in a visual studio
We'd like to make a few basic hook scripts that we can all share
If I make two iPhone applications, how can/should I share custom data (not contacts
I know that I can share files using Shared Folders in Virtual PC, but
Can someone share a simple example of using the foreach keyword with custom objects?
Does that mean that I can't share a Form between delphi 2007 and 2009?
Mono claims to be compatible with .NET. Have you tried it? Can you share
In C# you can use verbatim strings like this: @\\server\share\file.txt Is there something similar
I need to share SSO information between two different domains with a cookie, can
When using copy-on-write semantics to share memory among processes, how can you test if

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.