From 1a90eed470d9797c372bd951a515fb8c065f5f19 Mon Sep 17 00:00:00 2001 From: Simon Reynolds Date: Wed, 10 Nov 2021 12:09:50 +0000 Subject: [PATCH] Correct SQL in many-to-many scaffold sample (#3549) --- entity-framework/core/what-is-new/ef-core-6.0/whatsnew.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/entity-framework/core/what-is-new/ef-core-6.0/whatsnew.md b/entity-framework/core/what-is-new/ef-core-6.0/whatsnew.md index f7fd7723a2..81f5d6a428 100644 --- a/entity-framework/core/what-is-new/ef-core-6.0/whatsnew.md +++ b/entity-framework/core/what-is-new/ef-core-6.0/whatsnew.md @@ -1285,16 +1285,14 @@ CREATE TABLE [Posts] ( [Contents] nvarchar(max) NOT NULL, [PostedOn] datetime2 NOT NULL, [UpdatedOn] datetime2 NULL, - [BlogId] int NOT NULL, - CONSTRAINT [PK_Posts] PRIMARY KEY ([Id]), - CONSTRAINT [FK_Posts_Blogs_BlogId] FOREIGN KEY ([BlogId]) REFERENCES [Blogs] ([Id])); + CONSTRAINT [PK_Posts] PRIMARY KEY ([Id])); CREATE TABLE [PostTag] ( [PostsId] int NOT NULL, [TagsId] int NOT NULL, CONSTRAINT [PK_PostTag] PRIMARY KEY ([PostsId], [TagsId]), - CONSTRAINT [FK_PostTag_Posts_TagsId] FOREIGN KEY ([TagsId]) REFERENCES [Posts] ([Id]) ON DELETE CASCADE, - CONSTRAINT [FK_PostTag_Tags_PostsId] FOREIGN KEY ([PostsId]) REFERENCES [Tags] ([Id]) ON DELETE CASCADE); + CONSTRAINT [FK_PostTag_Posts_TagsId] FOREIGN KEY ([TagsId]) REFERENCES [Tags] ([Id]) ON DELETE CASCADE, + CONSTRAINT [FK_PostTag_Tags_PostsId] FOREIGN KEY ([PostsId]) REFERENCES [Posts] ([Id]) ON DELETE CASCADE); ``` These tables can be scaffolded from the command line. For example: