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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:02:07+00:00 2026-06-04T11:02:07+00:00

I have two entities – UserObj and Producer. UserObj stores user-related profile data Producer

  • 0

I have two entities – UserObj and Producer.

UserObj stores user-related profile data
Producer is a company that a userobj can be associated with. To associate these two I wanted to make an entity that lets me access the data of each from one entity.

I’m trying to link the two – but I’m not quite sure how to do it and I bet it is something small. Thanks for any and all help!

ProducerUser

    public class ProducerUser
{
    [ForeignKey("UserObj")]
    public Guid UserObjID { get; set; }
    [ForeignKey("Producer")]
    public int ProducerID { get; set; }

    public virtual UserObj UserObj { get; set; }
    public virtual Producer Producer { get; set; }

}

UserObj

    public class UserObj : Contact
{

    [Key]
    //public override string Email { get; set; }
    public Guid UserObjID { get; set; }
    [Display(Name = "First Name")]
   // [Required]
    public string FirstName { get; set; }
  //  [Required]
    [Display(Name = "Last Name")]
    public string LastName { get; set; }
    public int UserTypeID { get; set; }

    public virtual UserType UserType { get; set; }

    public static UserObj GetUserObj(string GUID, vfContext db)
    {
        Guid guidUser = new Guid(GUID);
        return db.UserObjs.Find(guidUser);
    }

    public string GetFullName()
    {
        return this.FirstName + " " + this.LastName;
    }

}

Producer

    public class Producer : Contact
{
    [Key]
    public int ProducerID { get; set; }
    public string Name { get; set; }
    public string Twitter { get; set; }


    public virtual ICollection<Wine> Wines { get; set; }

}
  • 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-04T11:02:10+00:00Added an answer on June 4, 2026 at 11:02 am

    To establish a many to many relationship add ICollection<> on both sides of the relationship. In your case:

    To the class Producer add

    public virtual ICollection<UserObj> UserObjs { get; set; } 
    

    To the class UserObj add

    public virtual ICollection<Producer> Producers { get; set; }
    

    After that you can remove the declaration of the class ProducerUser. EF will generate it for you.

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

Sidebar

Related Questions

I have two entities, EntityA and EntityB. EntityB can optionally be related to EntityA,
I have two entities User and Course. A user can take several courses which
I have two entities A and B that are related in a MxN relation
I have two entities one is Event and another is User. User can like
i have two Entities, Parent and Child, that are linked through a bidirectional one-to-many
I have two entities, a User and Role with a one-to-many relationship from user
I have two entities. User and Role. I am using Devise and CanCan. They
I have two entities: User and Event. Each user has a list of events
I have two entities. Groups. Pools. A Group can create many pools. So I
OK so I have two entities in my data model (let's say entityA and

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.