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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:53:03+00:00 2026-05-17T18:53:03+00:00

new to EF – please bear with me. Due to the way the database

  • 0

new to EF – please bear with me.

Due to the way the database was designed, in my model I have a User entity. The Contact entity inherits from the user entity, and the Profile entity inherits from the Contact entity.

How can I get a list of Profiles, and, how do I create a Profile?

I am able to get a list of Users no problem.

Your help is greatly appreciated!

  • 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-17T18:53:03+00:00Added an answer on May 17, 2026 at 6:53 pm

    For Entity Framework 4 Table-Per-Type Inheritance, you need 2 things:

    1. A “parent” table, and a “child” table. The “child” table should have a FK to the “parent” table’s PK.
    2. You need to setup an inheritance association in the EDM. If done correctly, you should see a arrowhead association between the entities, and the child table should have text in the name stating it’s parent.

    Now, you can get “Users” this way: (i assume you are already doing this)

    var allUsers = ctx.Users;
    

    Now getting “Contacts” is special – because it belongs to the “Users” entity set (you can prove this by looking at the properties for the “Contacts” entity).

    This is how you get Contacts:

    var allContacts = ctx.Users.OfType<Contact>();
    

    How does that work? Well OfType is an IEnumerable extension method which filters all the elements based on a given type. So it’s basically a foreach loop:

    foreach (var item in source)
    {
       if (item is Contact) result.Add(item);
    }
    

    Similarily, this is how you get Profiles:

    var allProfiles = ctx.Users.OfType<Profile>();
    

    To add a new Profile, again – add it to the “Users” entity set:

    var newProfile = new Profile { Name = "Foo" };
    ctx.Users.AddObject(newProfile);
    

    On a side note, i hope these tables are not relating to the ASP.NET Membership schema. If they are, stop right now. You should not map these tables via EF. Access the functionality via the regular Membership API.

    HTH.

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

Sidebar

Related Questions

The new extensions in .Net 3.5 allow functionality to be split out from interfaces.
New to DDD here and have a architecture question which should be a typical
New guy here so bear with me. Ive got a basic XSL file that
New to Objective C. I have created a few directories which contain pdf files
I have a new web app that is packaged as a WAR as part
I have found this example on StackOverflow: var people = new List<Person> { new
New to iOS, coming from the Java / Swing world, where I'm used to
New to Python, but I'm trying to...retrieve data from a site: import urllib.request response
New to Android development and have decided to use NetBeans 6.9.1 as my IDE.
New class is a subclass of the original object It needs to be php4

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.