You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
many-to-many documentation here doesn't seem to work. #4053
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.
ID: 24b2b50e-35f8-9e0b-8ce5-840e1ea816e6
Version Independent ID: 9e0e6e2c-48fa-76c3-3bd9-813a6df22645
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).
Activity
ajcvickers commentedon Sep 26, 2022
@jsangco What, specifically, doesn't work?
jsangco commentedon 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:
Then later has code like this (Please note the additional
sin the name)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).
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation
Major overhaul of the "relationships" documentation