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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:01:07+00:00 2026-05-30T07:01:07+00:00

Good day guys, I’ve got quite a specific data model that I’m trying to

  • 0

Good day guys,

I’ve got quite a specific data model that I’m trying to create in POCO classes, and I’ve tried so many different approaches and visited so many websites, but none seem to cover my specific example.

So I’m going to throw this out there and hope someone can help me.

I’ve got products, and products have ingredients. In our business though, these products can get supplied by different vendors, each with a slightly different set of ingredients.

So I’ve got my base classes:

public class Product
{  
    public int ProductID { get; set; }
    public string ProductNumber { get; set; }
    public string Description { get; set; }
    public virtual ICollection<Supplier> Suppliers { get; set; }
}

public class Vendor
{
    public int VendorID { get; set; }
    public string Name { get; set; }
    public virtual ICollection<Supplier> Suppliers { get; set; }
}

public class Ingredient
{
    public int IngredientID { get; set; }        
    public string Name { get; set; }
}

public class Supplier
{
    public int SupplierID { get; set; }

    public virtual ICollection<Product> Products { get; set; }
    public virtual ICollection<Vendor> Vendors { get; set; }
}

So as you can see, I’ve gotten as far as realising that my model needs a join entity, because my ingredients come from a specific vendor for a product, I need that join entity called supplier (I think).

This is where I am getting stuck… My product can be supplied by one or more vendors. Each vendor, per product, will have a list of ingredients for that product

I can’t even get past whether I need the join entity or not.

What would be awesome was if I could navigate the data structure like this (or something similar):

articles[1].Vendors[3].Ingredients;

Yet again, I don’t know enough about Entity Framework to know if this is possible.

The way I’m doing it now feels… wrong. What is the correct way to be doing what I want to do? Do I need the join table or can I somehow navigate the ingredients for a vendor for a product, maybe using the modelbuilder to make the product->vendor->ingredient link required?

Any help would be greatly appreciated!

Edit:
I also think I don’t understand enough about Entity Framework’s relationship ideas.

So one product can have multiple vendors, which is a 1-to-many relationship. But a Vendor can have many products. So is this actually a many-to-many?

I can definitely model what I want to do on a SQL Express server, but I really want to use Entity Framework. I just need a better understanding of my modelling requirements.

  • 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-30T07:01:08+00:00Added an answer on May 30, 2026 at 7:01 am

    It is not problem of EF. It is common entity-relationship task. You must simply improve your model. You can for example divide Product into two entities: ProductDefinition, ProductInstance

    public class ProductDefinition
    {  
        public int ProductID { get; set; }
        public string ProductNumber { get; set; }
        public string Description { get; set; }
        public virtual ICollection<ProductInstance> Instances { get; set; }
    }
    
    
    public class ProductInstance
    {
        public int ProductInstanceID { get; set; }
        public virtual Supplier Supplier { get; set; }
        public virtual ProductDefinition Definition { get; set; }
        public vritual ICollection<Ingredient> Ingredients { get; set; }
    }
    

    In your system you will work with ProductDefinition instead of original Product. This definition is like group of same products and it points to all possible manufacturings of products provided by different suppliers with different ingredients.

    I don’t know your context but it seems strange to count products with different ingredients as “same”.

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

Sidebar

Related Questions

good day guys! in project, among others, have models: class Category(models.Model): name = models.CharField(max_length
Good day to you guys I have an application that has a UITabBarController for
Good Day All we are trying to do is inside a trigger make sure
Good day, I receive data from a communication channel and display it. Parallel, I
Good day, I am having an issue trying to get the Text on a
Good day everyone, this is one of those areas that is a little over
Good day everyone. I have a question about making and using derived classes of
Good day guys, I've made a sweet favorites function with php mysql and ajax,
Good day. I'm trying to filter logs with get-winevent. When I working with local
Good day code knights, I have a tricky problem that I cannot see a

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.