ER diagram to SQL, as one script or a folder
Writing the script by hand after the drawing means typing every key again and getting the order right. ERDsmith writes it from the model: parents first, each table with its keys.

-- Table [shop].[Workshop] CREATE TABLE [shop].[Workshop] ( [WorkshopCode] CHAR (4) NOT NULL, [Title] NVARCHAR (80) NOT NULL, [Capacity] SMALLINT NOT NULL, [Price] DECIMAL (9, 2) NOT NULL, [Category] NVARCHAR (30) CONSTRAINT [DF_Workshop_Category] DEFAULT (N'general') NOT NULL, CONSTRAINT [PK_Workshop] PRIMARY KEY CLUSTERED ([WorkshopCode] ASC), CONSTRAINT [CK_Workshop_Capacity] CHECK ([Capacity]>(0) AND [Capacity]<=(40)) ); GO -- Table [shop].[Session] CREATE TABLE [shop].[Session] ( [WorkshopCode] CHAR (4) NOT NULL, [SessionNo] INT NOT NULL, [StartsAt] DATETIME2 (0) NOT NULL, [DurationMin] SMALLINT NOT NULL, [EndsAt] AS (dateadd(minute,[DurationMin],[StartsAt])), [HostId] INT NULL, CONSTRAINT [PK_Session] PRIMARY KEY CLUSTERED ([WorkshopCode] ASC, [SessionNo] ASC), CONSTRAINT [FK_Session_Member_HostId] FOREIGN KEY ([HostId]) REFERENCES [dbo].[Member] ([MemberId]), CONSTRAINT [FK_Session_Workshop_WorkshopCode] FOREIGN KEY ([WorkshopCode]) REFERENCES [shop].[Workshop] ([WorkshopCode]) );
shop.Workshop, then shop.Session's CREATE TABLE with its foreign keys; dbo.MemberNote, written between them, is left out here.01 · Navigate
Click a table, see its script
In the Export DDL tab a click on a table marks its block in the script, from its comment to its last statement.

02 · One script or a folder
One script, or one file per table
Write the project as one script, parents first, or in Chrome and Edge into a folder: one file per table, laid out as SqlPackage writes a SQL project.

03 · Errors
A table with an error stays out
A table with an error from the SQL Server check is held back with the foreign keys into it; the rest exports.

04 · Changes
See what changes before it's written
Against a folder, each file is tagged new, modified or dropped, and only the files that change are written.

By hand or from the model
| By hand | In ERDsmith | |
|---|---|---|
| Table order | worked out by hand, parents before children | parents first: it runs on an empty database in one go |
| Foreign keys | typed again from the lines on the drawing | written from the relationships, in each table's block |
| A renamed table's constraints | found and renamed in every script | renamed with it where they follow your naming templates; in a folder, the new file tagged new and the old one dropped |
| A table with an error | found when SQL Server refuses the script | held back with the foreign keys into it; the rest exports |
| A database project folder | a file per table, created and kept up by hand | one file per table as SqlPackage lays them out; only changed files written |