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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:08:16+00:00 2026-05-21T19:08:16+00:00

Lets say I have the following classes: public class User { public int UserId

  • 0

Lets say I have the following classes:

public class User
{
    public int UserId { get;set;}
    public string Firstname { get;set;}
    public Interests Interests { get;set;}
}
public class Interests
{
    public IList<Team> FavoriteTeams { get;set;}
    public IList<Food> FavoriteFoods { get;set;}
}
public class Team{
    public int TeamId { get;set;}
    public string City {get;set;}
    public string Name { get;;set;}
}
public class Food{
    public int FoodId { get;set;}
    public string FoodName { get;set;}
}

At the database level I would like to have the following tables:

Users
Teams
Foods
UserTeams
UserFoods

Basically I would like to have the Interests property of the user entity but not have a seperate table for it.

I am using EF 4.1 code first POCO classes. I know the easiest thing to do is put the Teams and Food collection as a property on the User, which is ok, but from the object model point of view I would like it be be its own property. Any idea of how I would acheive this type of mapping?

  • 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-21T19:08:17+00:00Added an answer on May 21, 2026 at 7:08 pm

    I would say: The mapping you are looking for is not possible, because:

    If you don’t want the class Interests to be mapped to a table, it must not be an entity and the Interests property in your User class must not be a navigation property. To avoid that EF interprets the Interests property as a navigation property, you would only have two options:

    • Mark it as NotMapped -> Does not help because you would lose the relationship from User to Team and Food completely
    • Mark the Interests class as ComplexType -> Not possible in your example because complex types are not allowed to contain navigation properties.

    That’s just from my level of understanding. It’s not unlikely that I overlooked another option.

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

Sidebar

Related Questions

With Castle Windsor, let's say I have the following classes: public class LowLevelComponent {
lets say i have the following XML <?xml version=1.0 encoding=utf-8?> <names> <name first=John last=Doe/>
Lets say I have the following setup: .... UISwitch gpsSwitch; // the below object
Lets say i have the following bit of code import java.sql.Connection; import java.sql.DriverManager; import
Lets say I have the following code in what we expect to become the
Possible Duplicate: To get parent class using Reflection on C# I am trying to
Let's say I release a code library as a standalone PHP class. Someone then
I am using class.forname to create a new instance of class.The classname comes from
I want to accept a Class object as a parameter to a constructor of
Okay, so i've studied c# and asp.net long enough and would like to know

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.