Draw a database diagram of your MS SQL database in dbdiagram.io.
- DbDiagramIo.MsSql: Library to export MS SQL database schema into a script that dbdiagram.io understands.
- Example.DotNetCore: .NET Core example application that actually creates the dbdiagram.io script by using the library.
- Example.DotNet461: .NET 4.6.1 example application.
cd src
and open the.sln
file with Visual Studio- set the connection string in
Example.DotNetCore\Program.cs
to point to your database - build the solution using Visual Studio
- run the application using
dotnet Example.DotNetCore.dll
- copy&paste the application's output to https://dbdiagram.io/d
- see your database's diagram
Use the DbDiagramIo.MsSql library in your code and create a better MS SQL => dbdiagram.io export tool.
dotnet add package DbDiagramIo.MsSql
using DbDbiagramIo.MsSql;
(TableDto[] tables, ForeignKeyDto[] foreignKeys) = MsSqlSchemaReader.ReadTablesAndForeignKeysFromDb( "<YOUR-DB'S-CONNECTIONSTRING>" );
foreach (TableDto table in tables)
{
Console.WriteLine( table.ToDbDbiagramCode() );
}
foreach (ForeignKeyDto fk in foreignKeys)
{
Console.WriteLine( fk.ToDbDiagramDto() );
}
SQL Server Management Studio 18 no longer supports diagrams. dbdiagram.io is a free tool to draw DB diagrams, however currently it does not have an "import from ms sql" feature. This project provided a quick & dirty way for me to generate DB diagrams for my MS SQL databases.
Copyright (c) 2019 David Zoltan. Licensed under the MIT license.