Support unidirectional many-to-many relationships
See original GitHub issueSupport shadow navigation properties such that views over the navigations can function even when a CLR type doesn’t have an actual navigation property. This would enable unidirectional many-to-many relationships like this:
class Post
{
public int Id { get; set; }
public ICollection<Tag> Tags { get; set; }
}
class Tag
{
public int Id { get; set; }
}
builder.Entity<Post>()
.HasMany(p => p.Tags)
.WithMany();
Original issue:
Are there any plans to support this?
table.Include(t => EF.Property<Entity>(t, "Property"))
Issue Analytics
- State:
- Created 8 years ago
- Reactions:90
- Comments:15 (7 by maintainers)
Top Results From Across the Web
JPA ManyToMany unidirectional relationship
Lets say we have two Entities, Entity Node and Entity Cluster . A Cluster has many Node s. A Node can belong to...
Read more >Hibernate @ManyToMany Unidirectional and Bidirectional
The Many-to-Many relationship can be best described by example. The example we're going to use is that of the relationship between an Author...
Read more >Introduction to Spring Data JPA Part 7: Unidirectional Many ...
In this article, we discuss how to create many-to-many, unidirectional relationships with Spring Data JPA.
Read more >Association Mappings with JPA and Hibernate
The bidirectional mapping models the relationship for both entities so that you can navigate it in both directions. The concept for the mapping...
Read more >Hibernate many-to-many unidirectional relationship
In the post, we are going to discuss a many-to-many unidirectional hibernate relationship. Many-to-many unidirectional relationship. We are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just a heads up, the documentation clearly states that single-property navigation is possible via a parameterless
WithMany()
https://docs.microsoft.com/en-us/ef/core/modeling/relationships?tabs=fluent-api%2Cfluent-api-simple-key%2Csimple-key#single-navigation-property-1
As of 6.0.2 this does not work, who is in charge of the docs?
I think using the following code may help to hide many-to-many navigation properties from out of entity types with current EF Core version(5.0.1)
Just mark the
Posts
property as private, ef core can work well and you can still use this navigation property insideTag
class. I prefer to field-only property, but it will make both navigations can not be loaded by explicit loading. See at #23717.