DataLinq Configuration Files
DataLinq uses JSON configuration files for the CLI and model-generation workflow.
There are two files:
datalinq.jsondatalinq.user.json
The CLI reads the main file first, then looks for a matching .user.json file next to it by replacing the extension. The user file is then merged on top.
What This Config Is For
This config is used by the datalinq CLI.
It is not required for runtime database access if you are instantiating MySqlDatabase<T>, MariaDBDatabase<T>, or SQLiteDatabase<T> directly in application code.
Config Discovery
By default, the CLI looks for datalinq.json in the current working directory.
You can also pass:
- a file path with
-cor--config - a directory path with
-cor--config, in which case DataLinq appendsdatalinq.json
If the main file is:
C:\repo\MyApp\datalinq.json
then the CLI will also look for:
C:\repo\MyApp\datalinq.user.json
Comments in JSON
The config reader strips both:
// single-line comments/* multi-line comments */
That means comment-bearing JSON examples work in practice even though standard JSON does not normally allow comments.
Minimal Example: MariaDB or MySQL
{
"Databases": [
{
"Name": "AppDb",
"CsType": "AppDb",
"Namespace": "MyApp.Models",
"SourceDirectories": [ "Models/Source" ],
"DestinationDirectory": "Models/Generated",
"Connections": [
{
"Type": "MariaDB",
"DataSourceName": "appdb",
"ConnectionString": "Server=localhost;Database=appdb;User ID=app;Password=secret;"
}
]
}
]
}
Generate models:
datalinq create-models -n AppDb
Generate SQL:
datalinq create-sql -n AppDb -o schema.sql
If you want MySQL instead of MariaDB, change "Type": "MariaDB" to "Type": "MySQL".
Minimal Example: SQLite
{
"Databases": [
{
"Name": "AppDb",
"CsType": "AppDb",
"Namespace": "MyApp.Models",
"DestinationDirectory": "Models/Generated",
"Connections": [
{
"Type": "SQLite",
"DataSourceName": "app.db",
"ConnectionString": "Data Source=app.db;Cache=Shared;"
}
]
}
]
}
The DataSourceName is also used as the default target file name for SQLite operations unless you override it with -d.
Using datalinq.user.json
The normal pattern is:
- keep shared structure in
datalinq.json - keep local connection details or secrets in
datalinq.user.json
Example shared config:
{
"Databases": [
{
"Name": "AppDb",
"CsType": "AppDb",
"Namespace": "MyApp.Models",
"SourceDirectories": [ "Models/Source" ],
"DestinationDirectory": "Models/Generated"
}
]
}
Example local override:
{
"Databases": [
{
"Name": "AppDb",
"Connections": [
{
"Type": "SQLite",
"DataSourceName": "app.local.db",
"ConnectionString": "Data Source=app.local.db;Cache=Shared;"
}
]
}
]
}
Important merge behavior
Overrides are applied per database name.
In practice, you should treat Connections as a replacing value, not as a deep-merged list. If you override a database entry in datalinq.user.json, include the full Connections array you want to use.
That matters for secrets too. If your shared config does not contain safe-to-commit connection strings, put the real connection details in datalinq.user.json and keep that file out of source control.
Database Object Fields
Each item in Databases describes one logical database definition.
Name
Required. Used by CLI selection via-n/--name.CsType
Optional. Defaults toName.Namespace
Optional. Defaults toModels.SourceDirectories
Optional. Source model paths used whencreate-modelsreads existing source models.DestinationDirectory
Optional in the raw schema, but effectively required for generation commands that write files.Include
Optional. Limits generation to selected tables or views.UseRecord
Optional. Defaults tofalse.UseFileScopedNamespaces
Optional. Defaults tofalse.UseNullableReferenceTypes
Optional. Defaults tofalse.CapitalizeNames
Optional. Defaults tofalse.RemoveInterfacePrefix
Optional. Defaults totrue.SeparateTablesAndViews
Optional. Defaults tofalse.Connections
Required by actual CLI usage. If no usable connections exist, commands that need a provider will fail.FileEncoding
Optional. Defaults to UTF-8 without BOM. Supported examples includeUTF8andUTF8BOM.
Connection Fields
Each entry in Connections describes one provider-specific connection.
Type
Required in practice. For the built-in CLI providers, useMySQL,MariaDB, orSQLite.DatabaseName
Optional alias. IfDataSourceNameis missing, this value is used instead.DataSourceName
Required in practice unlessDatabaseNameis present. This is the logical database name, server-side database name, or file name depending on provider.ConnectionString
Required in practice. The runtime connection-string parser expects a real connection string here.
Selection Rules in the CLI
- If the config contains more than one database, pass
-n. - If the selected database contains more than one connection type, pass
-t. - If the config path points to a directory, the CLI resolves
datalinq.jsoninside it.
Practical Notes
create-modelswrites generated files directly toDestinationDirectory.- When
--skip-sourceis not used,create-modelswill also read fromSourceDirectoriesif they are configured. - For SQLite, the CLI may rewrite the
Data Sourcevalue in the connection string based on the resolved target path.
Summary
datalinq.jsonis the main CLI config file.datalinq.user.jsonis the local override file discovered next to it.- Comments are allowed because the reader strips them before JSON deserialization.
- The safest pattern is to keep shared structure in
datalinq.jsonand local connection details indatalinq.user.json.