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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:00:55+00:00 2026-05-15T04:00:55+00:00

Im currently looking at migrating from fluent nHibernate to ADO.Net Entity Framework 4. I

  • 0

Im currently looking at migrating from fluent nHibernate to ADO.Net Entity Framework 4.
I have a project containing the domain model (pocos) which I was using for nHibernate mappings. Ive read in blogs that it is possible to use my existing domain model with EF4 but ive seen no examples of it. Ive seen examples of T4 code generation with EF4 but havent come accross an example which shows how to use existing domain model objects with EF4. Im a newby with EF4 and would like to see some samples on how to get this done.

Thanks
Aiyaz

  • 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-15T04:00:55+00:00Added an answer on May 15, 2026 at 4:00 am

    Quick walkthrough :

    • Create an entity data model (.edmx) in Visual Studio, and clear the “custom tool” property of the edmx file to prevent code generation
    • Create the entities in your entity data model with the same names as your domain classes. The entity properties should also have the same names and types as in the domain classes
    • Create a class inherited from ObjectContext to expose the entities (typically in the same project as the .edmx file)
    • In that class, create a property of type ObjectSet<TEntity> for each of you entities

    Sample code :

    public class SalesContext : ObjectContext
    {
        public SalesContext(string connectionString, string defaultContainerName)
            : base(connectionString, defaultContainerName)
        {
            this.Customers = CreateObjectSet<Customer>();
            this.Products = CreateObjectSet<Product>();
            this.Orders = CreateObjectSet<Order>();
            this.OrderDetails = CreateObjectSet<OrderDetail>();
        }
    
        public ObjectSet<Customer> Customers { get; private set; }
        public ObjectSet<Product> Products { get; private set; }
        public ObjectSet<Order> Orders { get; private set; }
        public ObjectSet<OrderDetail> OrderDetails { get; private set; }
    }
    

    That’s about it…

    Important notice : if you use the automatic proxy creation for change tracking (ContextOptions.ProxyCreationEnabled, which is true by default), the properties of your domain classes must be virtual. This is necessary because the proxies generated by EF 4.0 will override them to implement change tracking.

    If you don’t want to use automatic proxy creation, you will need to handle change tracking yourself. See this MSDN page for details

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

Sidebar

Related Questions

We are currently looking to adopt some type of standard developer framework and have
I am currently looking at migrating from maven2 to buildr and I am concerned
I'm looking into migrating our system to Windows Azure. Currently we have an automated
I'm currently looking at the Python framework Django for future db-based web apps as
I am currently looking at different ORM solutions for a project that is planned
I'm currently looking at indexing an ASP website from Sharepoint and I need to
We are currently evaluating options for migrating from hand-written persistence layer to ORM. We
We have an ASP.NET 3.5 app running in IIS6 we're migrating to IIS7 &
Our development team is currently looking into migrating our search system to Apache Solr,
We are currently looking at doing a partial migration away from a Main Frame.

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.