SQLQueryPilot
SQLQueryPilot is a Visual Studio Code extension for browsing database tables and generating C# EF Core files, TypeScript interfaces, and SQL scripts from a selected table.
Requirements
- Visual Studio Code 1.105 or newer.
- A reachable SQL Server, MySQL, or PostgreSQL database and credentials with permission to connect and read its schema.
- An open VS Code workspace folder. SQLQueryPilot writes generated files inside the first folder in the workspace.
You do not need to install Node.js to use the installed extension. Node.js is only needed if you are building SQLQueryPilot from source.
Install SQLQueryPilot
If SQLQueryPilot is available in the Visual Studio Code Marketplace, open Extensions (Ctrl+Shift+X), search for SQLQueryPilot, and select Install.
To install a VSIX provided by the SQLQueryPilot team:
- Open the Command Palette (
Ctrl+Shift+P).
- Run Extensions: Install from VSIX….
- Select the SQLQueryPilot
.vsix file and reload VS Code if prompted.
Add a database connection
- Open a VS Code workspace folder using File → Open Folder…. This is where generated files will be written.
- Open the SQLQueryPilot view in the Explorer. If it is not visible, open the Command Palette and run View: Open View…, then select SQLQueryPilot.
- Click the Add Connection button in the SQLQueryPilot view title. You can also run SQLQueryPilot: Add Database Connection from the Command Palette.
- Choose SQL Server, MySQL, or PostgreSQL.
- Enter a connection name, host, port, username, password, and optionally a default database. The usual ports are
1433 for SQL Server, 3306 for MySQL, and 5432 for PostgreSQL. Change the port if your server uses another one.
- Choose Verify server certificate unless you know the server uses a trusted private or self-signed certificate. In that case, choose Trust server certificate only if you trust that server.
- SQLQueryPilot saves the connection and password, tests the connection, and attempts to connect.
Connection settings are stored in VS Code, and passwords are stored using VS Code SecretStorage. They are not written to the workspace or SQLQueryPilot logs.
Browse the database
In the SQLQueryPilot Explorer, expand the connection, then Databases, a database, Tables, and a table. The table nodes show Columns and Foreign Keys. Column descriptions include the database type, nullability, and primary-key, identity, computed, or unique information when supplied by the database.
Use the connection context menu to Test Connection, Connect, Disconnect, or Remove Connection. Use Refresh on a database or Tables node to reload its contents. Removing a connection also removes its stored password. If a connection was saved but the test failed, remove it and add it again with corrected details.
SQLQueryPilot currently lists tables; views, stored procedures, and functions are not displayed. PostgreSQL only lists databases the connected role can access.
Run SQLQueryPilot: Configure Settings from the Command Palette, or open Settings (Ctrl+,) and search for:
@ext:Praxenfold.sqlquerypilot
| Setting |
Default |
Purpose |
sqlquerypilot.defaultNamespace |
SQLQueryPilot.Generated |
Namespace used by generated C# files. |
sqlquerypilot.outputDirectory |
generated |
Relative folder under your workspace for generated files. |
sqlquerypilot.defaultGenerator |
typescript |
Preferred generator, shown first in the generator picker. You still choose a generator for each run. |
sqlquerypilot.propertyNamingConvention |
camelCase |
Property casing for C# and TypeScript output: camelCase or PascalCase. |
sqlquerypilot.previewBeforeWrite |
true |
Show the generated content in an editor before offering to write it. |
The output directory must be relative to the workspace. Paths such as ../outside and absolute paths are rejected. SQLQueryPilot creates the configured folder if it does not exist. If you have a multi-root workspace, files are written under its first folder.
Generate code from a table
- Connect to a database and expand the tree to the table you want.
- Right-click the table and choose SQLQueryPilot: Generate Code from Table.
- Choose C# EF Core, TypeScript, or SQL scripts. The preferred generator from Settings appears first and is marked Default.
- Review the editor preview. Any generator warnings appear at the beginning of the preview.
- Choose Write Files to save the output, or Cancel to leave the workspace unchanged.
- If one or more output files already exist, confirm Overwrite to replace them. Choose Cancel to keep the existing files.
- SQLQueryPilot reports how many files it wrote. Choose Open Files in the notification to open them in editors.
When sqlquerypilot.previewBeforeWrite is false, the preview editor is skipped, but SQLQueryPilot still asks before writing and still confirms before overwriting files.
Generated files
- C# EF Core creates an entity class and a Fluent API configuration file for the selected table. The configured namespace is applied to both files. Review type-mapping warnings, especially for database-specific or lossy types.
- TypeScript creates a row interface and an insert interface for the selected table. Nullable row fields include
| null; nullable and database-generated fields can be omitted from the insert interface.
- SQL scripts creates one
.sql file for the selected table with CREATE TABLE, SELECT, INSERT, UPDATE, and DELETE sections. DML statements use provider-specific parameter placeholders. UPDATE and DELETE include a no-op WHERE 1 = 0 guard if a complete primary key is unavailable.
Generation is table-by-table. Review generated C# relationship warnings when foreign-key target tables are not part of the selected table's generation context. Generated SQL is only written as a file; SQLQueryPilot never executes it. Review scripts before running them against a database.
Try with a sample table
For a quick check, create a table in a scratch database, then refresh the database's Tables node in SQLQueryPilot.
SQL Server:
CREATE TABLE dbo.SQLQueryPilotSample (
Id int IDENTITY(1,1) NOT NULL PRIMARY KEY,
Name nvarchar(100) NOT NULL,
Description nvarchar(300) NULL
);
MySQL:
CREATE TABLE SQLQueryPilotSample (
Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
Name varchar(100) NOT NULL,
Description varchar(300) NULL
);
PostgreSQL:
CREATE TABLE public.sqlquerypilot_sample (
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name varchar(100) NOT NULL,
description text
);
The account used by SQLQueryPilot needs permission to see the database and its table metadata. Create sample tables only in a database where you are authorized to make schema changes.
Troubleshooting
- SQLQueryPilot view is missing: use View: Open View… in the Command Palette and choose SQLQueryPilot. If necessary, run Developer: Reload Window.
- Connection fails: verify the host, port, username, password, firewall rules, and database permissions. For a private or self-signed certificate, reconnect and choose the certificate option appropriate for your server.
- No databases or tables appear: confirm the account has permission to connect and read metadata. PostgreSQL filters the database list to databases the role can connect to.
- Generate command is unavailable: connect first, expand Databases → database → Tables, then right-click an individual table. Ensure a workspace folder is open.
- Generated files are not where expected: check
sqlquerypilot.outputDirectory and the first workspace folder in a multi-root workspace.
Privacy and safety
SQLQueryPilot connects directly from VS Code to the database you configure. It does not send schema or database contents to an external generation service. Passwords are kept in VS Code SecretStorage. Generated SQL is not run automatically, and existing files are only replaced after you confirm the overwrite prompt.