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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:31:01+00:00 2026-05-31T13:31:01+00:00

I am trying to find out how I can make a bridge table entity,

  • 0

I am trying to find out how I can make a bridge table entity, used for a many to many relationship, transparent to my model. I am using EF Database First.

Tables in question…(simplified)

Report
- ReportId INT PK
- ReportName VARCHAR(50)

Group
- GroupId INT PK
- GroupName VARCHAR(50)

ReportGroup
 - ReportId INT PK
 - GroupId INT PK

Current Class Structure…(simplified)

public class Report
{
     public int ReportId { get; set; }
     public string ReportName { get; set; }
     public IList<ReportGroup> ReportGroups { get; set; }
}

public class Group
{
     public int GroupId { get; set; }
     public string GroupName { get; set; }
     public IList<ReportGroup> ReportGroups { get; set; }
}

public class ReportGroup
{
     public int ReportId { get; set; }
     public Report Report { get; set; }
     public int GroupId { get; set; }
     public Group Group { get; set; }
}

Using the above, to get the groups that a Report belongs to requires something like this…

// Getting a report's groups
var report = this.ReportService.GetReportById(123456);
var groups = report.ReportGroups.Select(x => x.Group).ToList();

That’s not exactly something I want to be using throughout my application. Ideally, I’d like the bridge table and Entity (ReportGroup) to be transparent, allowing me to work with the entities like this…

// Getting a report's groups
var report = this.ReportService.GetReportById(123456);
var groups = report.Groups;

// Getting a group's reports
var group = this.ReportService.GetGroupById(1);
var reports = group.Reports;

So my question is whether this is possible with EF Database First, and if so, how do I wire this up correctly using the Fluent API in OnModelCreating().

Thanks in advance for the 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-05-31T13:31:02+00:00Added an answer on May 31, 2026 at 1:31 pm

    You if use ReportGroup just for relations you don’t need this POCO class just map it OnModelCreating:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
    ...
    modelBuilder.Configurations.Add(new GroupMap());
    ...
    }
    
    public class GroupMap : EntityTypeConfiguration<Group>
        {
            public GroupMap()
            {
                // Relationships
                this.HasMany(e => e.Reports)
                  .WithMany(set => set.Groups)
                  .Map(mc =>
                  {
                      mc.ToTable("groupreporttablename");
                      mc.MapLeftKey("GroupID");
                      mc.MapRightKey("ReportID");
                  });
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find out how can I used PHP interfaces in my
I'm trying to find out weather I can do this or not. I have
I'm trying to find out how I can do an early return in a
I'm trying to find out how I can iterate over the final results of
Im trying to find out a good JavaScript library that can create a nice
I'm trying to find out some matrix multiplication/inversion benchmarks online. My C++ implementation can
I'm trying to execute a SQL command, but I just can't find out why
I'm trying to find out whether I should be using business critical logic in
Hello i am trying to find out how can i print a file which
I have spent about 2 Days trying to find out how to make 3d

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.