This utility translates a plain text description of a relational database schema to a graphical entity-relationship diagram. The visualization is produced by using Dot with GraphViz. The output graph is a png image.
Here is an example of the output:
🎉 New: erd-dotnet can now automatically create the .er and png files when connecting to your postgress database.
erd-dotnet requires:
All of these are available for Windows, Mac and Linux. Dot must be in your path.
For linux, you should also install the font "Noto Color Emoji". For example (Debian / Ubuntu):
sudo apt install fonts-noto-color-emoji
erd-dotnet ERD_FILE OUTPUT_FILE [OPTION]
Where:
- ERD_FILE is the path of the erd file (.er format)
- OUTPUT_FILE is the path of the output file (.png or .txt)
Options:
Short | Long | Description |
---|---|---|
-f FMT | --format FMT | Select the output format to one of: dot, png (default) |
-d DB | --database DB | Obtains the schema from a database (Postgres only) |
DB
is a database connection string like: Host=192.168.XXX.XXX:5432;Username=user;Password=pwd;Database=my_database;
, see Npgsql doc
🚨 By default, the output will be a png file. This requires Dot to be installed.
🌐 Alternatively you can use the dot option and use an online tool: Copy and paste the contents of the .dot file into an online graphviz viewer
The er
format is a text file that can easily be updated.
The name of the table is enclosed in [
]
, followed by the names of the columns in the following rows. A primary key is preceded by *
, a foreign key by +
. Note that a column may be both a primary key and a foreign key.
The relationships between the tables are expressed as follows:
table1 *--1 table2
The cardinality is expressed as:
Cardinality | Syntax |
---|---|
0 or 1 | ? |
exactly 1 | 1 |
0 or more | * |
1 or more | + |
[Person]
*name
height
weight
birth
+location_id
You need .net 8 SDK.
Build:
dotnet build
Run:
dotnet run
This work is based on the work of: