-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support unidirectional many-to-many relationships #3864
Comments
No plans for EF Core RTM. We are going to enable unbound navigation properties only in metadata so that they can be used in the model snapshot for Migrations (see #2140) but we plan to block their use in runtime scenarios. Anyway, in case we decide to enable this feature in the future. Could you explain how you expect it to work and how you would take advantage of it? |
TL;DR I'm closing this as it might be only beneficial for a very specific use-case and by using extension methods and casting, I got it to work in the end without hurting performance (I hope). The only reason why someone might find this beneficial is if they're using a generic repository pattern. Suppose I have these DTOs in my "Core" project without a reference to EF Core.
.. and these DTOs are from a separate project with a reference to EF Core. They inherit from the Core DTOs. You could argue that
I would configure my DBContext like so,
Here's my generic repository interface:
and the EF implementation of that interface:
This is where I would find this helpful: Suppose I have this interface in my core as well:
and my implementation from the class that has a reference to EF Core:
Since in my All this crazy abstraction is so that we can swap out different implementations of different services as we move multi-platform on our project. |
Thanks. From the description I understand that your scenario is that you want to apply a very specific workaround to a limitation of EF (ideally you should be able to map the Keywords property) while keeping layers above the repository persistence agnostic. I believe there are other scenarios in which not having a navigation property in the CLR type but still being able to refer to it in LINQ queries could be more generally useful, so I will reopen the issue for triage. |
I think you might be referring to the
I'm pretty sure there is and this would probably be especially useful when abstracting things although I could not think of anything at the moment except what I've given so far. |
Any updates on the subject? |
Not yet. We have higher priority features on the backlog, so this won't be in the first round of features we pick to implement. |
Once #1368 (comment) and #8881 are both implemented then, given (1) a many-to-many relationship between Product and Org and (2) a many-to-many shadow navigation property
So I need to tack the
If support for this syntax isn't yet planned, then please address this issue (or #6412 but it's closed.) to enable this scenario. |
Is there any update on this? It would be great to see unidirectional many-to-many relationships being supported soon! |
One of the Object oriented features in the model is to limit the visibility of one entity. |
@luizfbicalho @ab-tools This issue is in the Backlog milestone. We are currently planning EF Core 6.0 and there is a good chance this feature will make the cut. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to add your vote (👍) at the top. |
modelBuilder.Entity < Dependent > ()
.ToTable("Dependent")
.HasMany < Superior > ()
.WithMany (m => m .Dependents);
|
Just a heads up, the documentation clearly states that single-property navigation is possible via a parameterless As of 6.0.2 this does not work, who is in charge of the docs? |
@freer4 At the very bottom of every docs page there is a link where you can report issues about problems for that doc specifically. It gives the team everything they need to know in order to fix the issue. |
Support 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:
Original issue:
The text was updated successfully, but these errors were encountered: