-
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
LINQ query not working properly for many-to-many relationship entities in EF core #22801
Comments
Please share a runnable repro code which demonstrate issue you are seeing. |
I'm not allowed to share my source files. However, whatever I've provided above is very similar to what I'm using in my modules. All I'd like to know is if there is anything I'm missing wrt configuring m2m relationship in efcore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have two entities in my database schema which has many-to-many relationship. I followed the EF core documentation (https://docs.microsoft.com/en-us/ef/core/modeling/relationships?tabs=fluent-api%2Cfluent-api-simple-key%2Csimple-key) by setting up a bridge table and mentioning the foreign key in DbContext appropriately. However, when I try to query my db using the LINQ query (see below), it's simply returning only the parent object and returning null for my child objects. I've setup a navigation property appropriately.
Also configured the composite keys using fluent api as shown below:
I tried to parse the underlying SQL query using SQL studio profiler which is executing the correct sql queries and the results are also returned accurately. It's only when the results are returned back, it's not getting displayed properly. My class structure is as given below. Group and Member are the entities that have many-to-many relationship and GroupMember is my bridge entity class. Is this an issue or am I doing something wrong here.
The text was updated successfully, but these errors were encountered: