Command Line Tools Reference
LightSpeed includes the following command line tools.
lsgen – Create Entity Classes from Database
The lsgen tool creates entity classes from a database. It can also be used to create a .lsmodel file which can then be loaded into the designer for further development.
Syntax: lsgen /p:provider /c:connection_string /l:language /n:namespace /o:output_dest
· provider: The type of database. See below.
· connection_string: The database connection string.
· language: The language to generate the entity classes in.
· namespace: The namespace into which to generate the classes.
· output_dest: Where to save the generated files. When generating C# or Visual Basic files, this must be the name of a folder. The folder is created if it does not already exist. Existing files at this location are overwritten.
lsgen also supports the following optional switches:
· /linq: Generate a strong-typed LINQ unit of work class.
· /contracts: Generate WCF data contracts.
· /m:model_name : Specifies the model name for LINQ or WCF class names
· /include:tables : Include only the specified tables in the generated model.
· /exclude:tables : Exclude the specified tables from the generated model.
· /stp:prefix : The prefix to be stripped from table names if present (e.g. tbl).
· /src:prefix : The prefix to be stripped from column names if present (e.g. col).
· /template:template_file : Use a custom code generation template.
The tables argument to the /include and /exclude switches is either a comma-separated list of table names, or the @ character followed by the name of a file containing the list of tables, one per line. E.g. /include:Cars,Engines or /exclude:@CarTables.txt. Associations are generated regardless of whether the association target type is generated, so care is required to avoid “dangling” associations.
Individual columns can be excluded using table.column notation, e.g. MyTable.UnwantedColumn, or *.column to exclude columns of that name no matter which table they are in.
To create a designer model using lsgen, specify /l:lsmodel. In this case, the output destination (/o) must be a file, not a folder. lsgen does not generate any layout for the generated model: it is up to you to make the diagram look good by loading it into Visual Studio and dragging the entities into a suitable layout.
You can also generate C# or Visual Basic files from a LightSpeed designer model using lsgen. This is not normally necessary because Visual Studio automatically generates the appropriate code, but it may be useful in certain automation scenarios. To do this, specify /p:lsmodel, and pass the model (.lsmodel) filename as the /c (connection string) option.
lsmigrate – Apply Migrations
The lsmigrate tool applies migrations, supplied as source code, to a database.
Syntax: lsmigrate provider connection_string [to_version]
· provider: The type of database. See below.
· connection_string: The database connection string.
· to_version: The version to which to migrate the database. If omitted, the latest version will be selected.
Database Providers in Command Line Tools
The ‘provider’ argument for command line tools can take the following values:
Value | Database | Abbreviation |
MySql5 | MySQL | mysql |
Oracle9 | Oracle | oracle |
PostgreSql8 | PostgreSQL | pg |
Sqlite3 | SQLite | sqlite |
SqlServer2000 | Microsoft SQL Server 2000 | sql2000 |
SqlServer2005 | Microsoft SQL Server 2005 | sql2005 |
SqlServer2008 | Microsoft SQL Server 2008 | sql2008 |
SqlServer2012 | Microsoft SQL Server 2012 | sql2012 |
SqlServerCE | Microsoft SQL Server Compact 3.5 | sqlce |
SqlServerCE4 | Microsoft SQL Server Compact 4 | sqlce4 |
VistaDB4 | VistaDB | vdb4 |
Languages in Command Line Tools
The ‘language’ argument for command line tools can take the following values:
Value | Language | Abbreviation |
CSharp | C# | cs |
VisualBasic | Visual Basic | vb |