Generate SQL Create Scripts for existing tables
whibdev opened this issue · 2 comments
whibdev commented
Is there a property or method to capture a create sql script for an existing table in a connected database? I've started looping through each table in the DatabaseSchema.Tables and writing out the column properties, but I'm thinking this functionality must already be built in (although I can't seem to find it). Any help would be great.
martinjw commented
var factory = new DdlGeneratorFactory(SqlType.SqlServer); //adjust database type
var tableGenerator = factory.AllTablesGenerator(databaseSchema);
tableGenerator.IncludeSchema = false;
var ddl = tableGenerator.Write(); //string with CREATE TABLE statements + relationships+indices
whibdev commented
This works for me