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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:14:01+00:00 2026-05-27T10:14:01+00:00

I am working with a legacy database that cannot have its structure changed (at

  • 0

I am working with a legacy database that cannot have its structure changed (at least not yet), and it has something like this:

**Profile**:
profile_id
first_name
last_name

**OneBigLookupTableToRuleThemAll**:
lookup_id (PK)
category_id (PK) (refers to a recrod in a OneBigCategoryTableToRuleThemAll)
description (basically a label)

**ProfileProperties**:
property_key (PK GUID)
profile_id  
lookup_id 

UNIQUE constraint on profile_id, lookup_id

As an example of two categories:

Degrees (MD, PhD, MS, MPH, etc) -- cat_id 1, for example
Job Responsibilities (Statistician, Medical Doctor, Epidemiologist, etc) -- cat_id 2

So, in the Lookup table, we end up with stuff like this:

lookup_id, cat_id, description
1        , 1     , MD
2        , 1     , PhD
3        , 1     , MS
4        , 1     , MPH
5        , 2     , Statistician
6        , 2     , Medical Doctor
7        , 2     , Epidemiologist

Thus, in the ProfileProperties table we end up with stuff like:

property_key, profile_id, lookup_id
some guid     , 1         , 1        -- MD degree
some guid     , 1         , 4        -- MPH degree
some guid     , 1         , 6        -- Medical Doctor

I would like to have an entity like this:

public class Profile {
  public int ProfileId { get; }
  public string FirstName { get; set; }
  public string LastName { get; set; }

  public ICollection<JobResponsibility> JobResponsibilities { get; set; }
  public ICollection<Degree> Degrees { get; set; }
}

public class JobResponsibility {
 public int Id { get; set; }
 public string Description { get; set; }
}

public class Degree {
 public int Id { get; set; }
 public string Description { get; set; }
}

— Actually, in the setters of the Id, I would like to constrain the value to one of the actual values that is in the database, though I’m not sure I’d go to full blown Enum-type support (and I know code first does not support that yet)

I believe one of the EntityFramework mapping scenarios should be able to handle this, but I’m having trouble figuring out what I need to do to get this to work.

Anyone have any tips or resources I can read up on this kind of scenario? I’m thinking it’s actually going to end up very basic, but I’m new to EF.

Thank you,
Josh

  • 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-27T10:14:01+00:00Added an answer on May 27, 2026 at 10:14 am

    I don’t think that any entity framework mapping (especially if we talk about fluent / code-first) is able to map that directly – I just tested approach with inheritance and it didn’t work. EF is heavily dependent on the way how database is designed. In your case you will most probably end with something like this:

    public class Profile
    {
        public int ProfileId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public virtual ICollection<ProfileProperty> Properties { get; set; }
    }
    
    public class ProfileProperty
    {
        public Guid PropertyId { get; set; }
        public int ProfileId { get; set; }
        public int PropertyId { get; set; }
        public virtual Profile Profile { get; set; }
        public virtual Property Property { get; set; }
    }
    
    public class Property
    {
        public int LookupId { get; set; }
        public int CategoryId { get; set; }
        public string Description { get; set; }
    }
    

    Now if you want to have properties like Degrees you will have to add non mapped property like:

    public IEnumerable<Property> Degrees
    { 
        get { return Properties.Where(p => p.Property.CategoryId == 1)
                               .Select(p => p.Property);
    } 
    

    It will work only for reading but not for modifying properties. For modification you will need more complex logic to build correct structure inside real Properties collection.

    Even support of enums planned to .NET 4.5 would not solve it. Enums will support only representing single integral column as enum but in your case you need to decompose many to many relation to many enums.

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

Sidebar

Related Questions

Im working on a legacy database, that cant be changed. I have a table
I have recently started working on a legacy application that has most of its
I'm working on a legacy database table that has a phone no. field but
I am working with a legacy database that has a table to store up
I am working with a legacy database schema that looks like this: product_table table
I have a legacy database that I am working with a basic column layout
I have a 'legacy' DB2 database that has many other applications and users. Trying
I'm working on a legacy database that is complete non-sense. I have a table
I have a legacy database that I'm working on getting ActiveRecord to work with.
I'm working on some legacy code and I ran into something that I'm not

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.