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

  • Home
  • SEARCH
  • 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 4589476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:04:41+00:00 2026-05-21T22:04:41+00:00

I recently came by the class ManyNavigationPropertyConfiguration<TEntity, TTarget> , and within that class there

  • 0

I recently came by the class ManyNavigationPropertyConfiguration<TEntity, TTarget>
, and within that class there I found a method named WithMany() with 2 overloads.

The first overload:
WithMany()

Configures the relationship to be
many:many without a navigation
property on the other side of the
relationship.

The second overload:
WithMany(Expression<Func<TTarget, ICollection<TEntity>>>)

Configures the relationship to be
many:many with a navigation property
on the other side of the relationship.

Now is my question, why would you configure a relationship to be many:many without a navigation property (the first overload)? I dont see any scenarios where that would be helpful… Any thoughts?

  • 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-21T22:04:42+00:00Added an answer on May 21, 2026 at 10:04 pm

    An example might be this model:

    public class User
    {
        public int UserId { get; set; }
        public string Name { get; set; }
        public ICollection<Role> Roles { get; set; }
    }
    
    public class Role
    {
        public int RoleId { get; set; }
        public string Description { get; set; }
    }
    

    If you are never interested to retrieve all users which are in a specific role, adding a navigation property …

    public ICollection<User> Users { get; set; }
    

    … to the Role class would be unnecessary overhead.

    But you still must EF tell that a many-to-many relationship between User and Role exists …

    modelBuilder.Entity<User>()
                .HasMany(u => u.Roles)
                .WithMany();
    

    … because the default convention mappings would create a wrong relationship, namely a one-to-many relationship, corresponding to this mapping:

    modelBuilder.Entity<User>()
                .HasMany(u => u.Roles)
                .WithOptional();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was working on some code recently and came across a method that had
I recently came across some weird looking class that had three constructors: class Class
I recently came upon a static method declared as: public class Foo { public
I recently came across the Java DefaultMutableTreeNode class. I was wondering if there is
I recently came across an IE7 only bug that I thought I'd share so
I recently came across a ASP 1.1 web application that put a whole heap
Question So I've recently came up with some new possible projects that would have
An interesting issue came up recently. We came across some code that is using
What is scchema importer Extension class in .net webservice.Recently i came across this class
I recently came across an article by Matthew Weier O'Phinney (ZF project lead) that

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.