LINQ to DB CLI is a dotnet tool for Linq To DB database model scaffolding.
$ dotnet add package linq2db.cliNOTE: This is not a library you could reference from your project, but command line utility, installed using
dotnet toolcommand (see installation notes).
See this page for more detailed help.
Requires .NET 8 or higher.
Install as global tool:
dotnet tool install -g linq2db.cli
Update:
dotnet tool update -g linq2db.cli
General information on .NET Tools could be found here
To invoke tool use dotnet-linq2db <PARAMETERS> or dotnet linq2db <PARAMETERS> command.
Available commands:
dotnet linq2db help: prints general helpdotnet linq2db help scaffold: prints help for scaffold commanddotnet linq2db scaffold <options>: performs database model scaffoldingdotnet linq2db template [-o template_path]: creates base T4 template file for scaffolding customization codeFor list of available options, use dotnet linq2db help scaffold command.
This command uses minimal set of options, required for scaffolding (database provider and connection string) and generates database model classes in current folder.
dotnet linq2db scaffold -p SQLite -c "Data Source=c:\Databases\MyDatabase.sqlite"
This command demonstrates use of configuration file with scaffold options combined with command line options.
dotnet linq2db scaffold -i database.json -c "Data Source=c:\Databases\MyDatabase.sqlite"
database.json file:
{
"general": {
"provider": "SQLite",
"connection": "Data Source=c:\\Databases\\TestDatabase.sqlite",
"output": "c:\\MyProject\\DbModel",
"overwrite": true
}
}
Here you can see that connection string passed using both command line and json config file. In such cases option passed in command line takes precedence.
Scaffold configs (response files) are convenient in many ways: