The two main usage of DbTools is
- Describe a database schema and properties in C# code, with the ability to generate the database on multiple database engines
- Provide a command line tool, DbTools.Console to execute DbTools functions (examples: generating database documentation or comparison to an Excel file, generate database definition as .cs files)
A very simple database definition looks like this (from TestDatabaseSimpleTyped.cs):
namespace FizzCode.DbTools.DataDefinition.Tests
{
using FizzCode.DbTools.DataDefinition.Generic;
using FizzCode.DbTools.TestBase;
public class TestDatabaseSimpleTyped : TestDatabaseDeclaration
{
public Company Company { get; } = new Company();
}
public class Company : SqlTable
{
public SqlColumn Id { get; } = Generic1.AddInt32().SetPK().SetIdentity();
public SqlColumn Name { get; } = Generic1.AddNVarChar(100);
}
}
Build, and run FizzCode.DbTools.Console.exe (DbTools\artifacts\bin\DbTools.Console\debug\FizzCode.DbTools.Console.exe)
Option examples:
FizzCode.DbTools.Console.exe document --connectionString "<connection string>" --sqlType MsSql2016 --patternFileName "" --flags None
FizzCode.DbTools.Console.exe changedocument --connectionStringOriginal "<connection string>" --connectionStringNew "<connection string>" --sqlTypeOriginal MsSql2016 --sqlTypeNew MsSql2016 --patternFileName "" --patternFileNameOriginal "" --patternFileNameNew "" --flags None
See LICENSE.
Regarding pull requests or any contribution
- we need a signed CLA (Contributor License Agreement)
- only code which comply with .editorconfig is accepted
Console project which accepts commands to execute DbTools features.
Contains classes for database definitions.
Generates database documentation from DatabaseDefinition.
Executes the database creation sql commands from the DataDefinitionGenerator, to create the database.
Generates executable sql to create database from DatabaseDefinition.
Builds DatabaseDefinition from an existing database.
Generates data, typically for testing purposes, based on DatabaseDefinition.
Contains helper classes for unit testing DbTools.
Configuration values are stored in config.json files. Configuration values for tests are stored in testconfig.json files.
You can use local config values to override content of these files, which are local (developer specific), or not desired to be included in source control (for example, a connection string with username and password to an internal environment). Use naming as config-local.json and testconfig-local.json.
To run unit tests in parallel between assemblies, you have to enable it by selecting Test Explorer / Configure Run Settings / Select solution wide runsettings file, and then select the file \Tests\test.runsettings