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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:31:17+00:00 2026-05-28T19:31:17+00:00

Quick question that requires a long explanation.. Say I have two tables – one

  • 0

Quick question that requires a long explanation..

Say I have two tables – one is an item table (say ‘Users’) and another is a definition table – like ‘Custom Properties’. Many different items in the system (‘Users’, ‘Articles’, ‘Posts’, etc) can all have custom property defined to them, and these are stored in the ‘Custom Properties’ table. So, for example, the ‘Custom Properties’ table looks like:

CREATE TABLE [CUSTOMPROP_DEFINITION] (
    [ITEM_TYPE] INTEGER NOT NULL,
    [POSITION] INTEGER NOT NULL,
    [NAME] NVARCHAR(MAX) NOT NULL
)

Simple little table. Each item has a ‘item_type’ id (for example, a user is an item type of 1. Article would be an item type of 2, and so on), so this table could have multiple rows for each item. Essentially, this table’s metadata for the other tables.

I want to create a navigation property on my Users table, that will link to all the entries in the props table where ‘item_type’ == 1.

What’s the best way of going about this? From the way I see it, there are two options –
(1) Creating a navigation property through the EDMX and letting it populate it automagically. (This is preferred, but having troubles implementing..) or

(2) Creating a property in the partial class, and having that load everything manually.

The issue with #2 is that it would (could potentially?) be slower than having the entity framework handle loading.
The issue with #1 is that.. no matter what I try, I can’t get a NavigationProperty defined that will handle it. Because the primary key is a fixed number – i.e. It will always be ‘1’ for ALL Users, always be ‘2’ for all articles, etc.. – I haven’t been able to find a way to hook into that.

Thoughts?
–Mike.

  • 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-28T19:31:20+00:00Added an answer on May 28, 2026 at 7:31 pm

    What you’re describing isn’t really a “Navigation Property” in terms of what EF defines as a naviation property. A navigation property in EF terms follows a [usually] primary key – foreign key reference in the database schema itself. And, AFAIK, the only way to get that navigation property in the EDMX is for there to actually be a FK involved.

    You could, obviously (and probably do) have a FK here, but that’s not entirely what you want, because that FK is going to return all instances of your custom properties for the given primary key. What you want is instances of only a particular type; and I don’t think there is a “off the shelf” way of doing this in EF.

    What you probably want to do is implement a Stored Procedure, and bring that into your model; you could then implement this is a property (or probably more appropriately a method) on your entity.

    Alternatively, you could just create the FK, have your entity load all of the custom properties, and then write “helper properties” that do simple LINQ based .Where() filters.

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

Sidebar

Related Questions

just a question that needs a quick answer, I have a Action, lets say,
Quick question/clarification required here. I have a DB table that will quite possibly have
Quick question... I have a query that checks for duplicates that looks like this:
Quick question. I have an app that use a native DLL through PInvoke, this
Quick question. What do you think, I have a few sites that use a
Hey guys quick question, I have an entry that I put in my database,
Hey guys quick question. I have a div that gets assigned a number to
Just a quick question about best practice in MVC development. Let's say that I've
Quick question, looking for some recommendations. I have a site that will be requesting
A quick question. I've got two textboxes running server side and have their visibility

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.