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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:06:57+00:00 2026-06-16T02:06:57+00:00

I am building a website using .NET MVC 4. What I have is Persons

  • 0

I am building a website using .NET MVC 4. What I have is Persons that have roles in regard to other Persons. For example A is Father to B,D and A is Husband to C.

I am not sure if this is the right way to do it but I was thinking of having a class Persons and a class Roles. Somehow I want to connect an instance of Persons with another instance of Persons through an instance of Roles and save that in the database.

So the association table will have to have three columns Person1|Role|Person2.

How can I best represent this in a model?

EDIT

Thanks for the help. I did something pretty similar to what you proposed.

public class Persons
{
    public Guid PersonsID { get; set; }
    public string Name { get; set; }
    ICollection<Relations> Relations { get; set; } 

}

public class RelationshipType
{
    public Guid ID {get; set;}
    public string Type { get; set; }
    public ICollection<Relations> Relations { get; set; }

}

public class Relations
{
    public Guid RelationsID { get; set; }
    public virtual Persons RealtedPerson { get; set; }
    public virtual RelationshipType RelationType { get; set; }
    public virtual Persons RealtedTo { get; set; }
}

This gave three tables where the table Relations has two foreing keys towards Persons and one foreign key towards RelationshipType. No if I remove a person the relation including this person maybe removed as well.

One final question. Why did you opted for an enum rather a class resulting in a table?

Thanks again for your help.

  • 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-06-16T02:06:59+00:00Added an answer on June 16, 2026 at 2:06 am

    You should do something like this then

    class Person{
       string Id{ get; set; }
       string Name{ get; set; }
       ...
       List<Relation> relations{ get; set; }
    
    }
    
    class Relation
    {
       string id{ get; set; }
       Person relatedPerson{ get; set; }
       RelationType relationType { get; set; }
       Person relatedto { get; set; }
    }
    
    enum RelationType{
      Husband,
      Father,
      Child,
      ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a website using ASP.NET MVC and entity framework. I have a
I am building a website using php and mysql.I have a login that is
i have been building websites using vs 2008 (mostly asp.net mvc, jquery and webforms).
I'm looking at building a templating engine for my website. I'm using ASP.NET MVC
I'm building a web site (using ASP.NET, MVC 3, Razor) and I'm not using
i am building a website using asp.net mvc and jquery. as a best practice
I have an existing website developped using ASP.NET MVC 3 and Entity Framework 4
I'm going to be building a website using ASP.NET and C# that will be
I'm about to begin building a website using the ASP.NET MVC framework and I'm
I'm building a website in ASP.Net, using MVC, and need to list a set

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.