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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:15:20+00:00 2026-06-09T10:15:20+00:00

I have this aggregate root CustomerGroup int Id string Name Customer[] Customers And this

  • 0

I have this aggregate root

CustomerGroup
int Id
string Name
Customer[] Customers

And this one

Customer
int Id
string Name

My model was built using EF 4. What i’d prefer would be (for sticking to the concept of aggregate root)

CustomerGroup
int Id
string Name
int[] Customers

How would you do this ?

A customer might be in many gorup (many to many relationship) but I only need the relationship in one way group -> customer. I don’t have any use case where I need customer -> group.

  • 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-09T10:15:21+00:00Added an answer on June 9, 2026 at 10:15 am

    As you have a many-to-many association between Customer and CustomerGroup there also is a so called junction table, let’s say CustomerGroupCustomer, that has CustomerId and CustomerGroupId.

    If this table only has these two fields EF can use it implicitly, which means that CustomerGroup can have a Customers collection where in the mapping you indicate that CustomerGroupCustomer is the junction table. Here is an example. You can, but don’t have to, map Customer.CustomerGroups. When working database-first, this implicit behaviour is the default.

    However, since you’re interested in CustomerIds only you could decide to have a regular one-to-many association CustomerGroup.CustomerGroupCustomers. If you address this navigation property only one join is required and the query is pretty light. If you have a CustomerGroup instance you can do

    group.CustomerGroupCustomers.Select(c => c.CustomerId)
    

    and only the CustomerIds will be queried.

    If you want you can get the Customers directly by doing

    group.CustomerGroupCustomers.Select(c => c.Customer)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing this query: SomeObject.objects.annotate(something=Avg('something')).order_by(something).all() I normally have an aggregate field in my model
I have Person class which is root of its aggregate, this aggregate also contains
I have the following entities in my domain model. A group (an aggregate root)
I have been struggling with this error for more than two hours: error: aggregate
I have this string 2012-06-27 16:17:06 and I want to convert it to GMT
I have an aggregate root Order with corresponding OrderService and OrderRepository . I have
I am having StudentDriver as aggregate root. Each StudentDriver may have multiple DrivingLogs and
I have some problems designing the aggregate root. Here is how I see it
If I have an aggregate root which consists of say: class Parent { IEnumerable<Child>
I'm struggling with aggregates and aggregate roots. I have a natural aggregate root which

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.