Skip to content
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

many-to-many documentation here doesn't seem to work. #4053

Closed
jsangco opened this issue Sep 23, 2022 · 2 comments · Fixed by #4269
Closed

many-to-many documentation here doesn't seem to work. #4053

jsangco opened this issue Sep 23, 2022 · 2 comments · Fixed by #4269

Comments

@jsangco
Copy link

jsangco commented Sep 23, 2022

Could be something I'm missing of course, but I've tried several times following along with the code examples and the many-to-many relationship code doesn't seem to work.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@ajcvickers
Copy link
Member

@jsangco What, specifically, doesn't work?

@jsangco
Copy link
Author

jsangco commented Sep 30, 2022

Follow the example code in the provided documentation. The many-to-many relationship does not work.

After spending quite a bit of time debugging it, I figured out that it is due to the fact that EFCore does not pluralize its DbSet names anymore. This is problematic for people using a DB first method expecting the singular table names to map to pluralized proprieties.

Additionally, there's just generally poor consistency with table and property names in the sample code; thus leading to confusion. For example, the document has a table definition like this:

CREATE TABLE [PostTag] (
    [PostsId] int NOT NULL,
    [TagsId] nvarchar(450) NOT NULL,
    CONSTRAINT [PK_PostTag] PRIMARY KEY ([PostsId], [TagsId]),
    CONSTRAINT [FK_PostTag_Posts_PostsId] FOREIGN KEY ([PostsId]) REFERENCES [Posts] ([PostId]) ON DELETE CASCADE,
    CONSTRAINT [FK_PostTag_Tags_TagsId] FOREIGN KEY ([TagsId]) REFERENCES [Tags] ([TagId]) ON DELETE CASCADE
);

Then later has code like this (Please note the additional s in the name)

j.ToTable("PostTags"));

I would recommend going through the sample code for the many-to-many relationship and ensuring it can be used to execute working code (for both code-first and db-first if possible).

@ajcvickers ajcvickers added this to the Backlog milestone Oct 5, 2022
@ajcvickers ajcvickers self-assigned this Feb 23, 2023
@ajcvickers ajcvickers modified the milestones: Backlog, 8.0.0 Feb 23, 2023
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Feb 25, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Mar 19, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Mar 28, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
ajcvickers added a commit that referenced this issue Mar 30, 2023
Fixes #4145
Fixes #4053
Fixes #3900
Fixes #3810
Fixes #3668
Fixes #3648
Fixes #3282
Fixes #3282
Fixes #2924
Fixes #2807
Fixes #2494
Fixes #2321
Fixes #2266

Part of #3996
@ajcvickers ajcvickers removed their assignment Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants