CreateSQLServerDatabase
Creates database on SQL Server. Used often before DBUp migrations.
Library allow us to create database from code. Database object exposes three methods:
- Create – it creates database. If database exists throws exception
- CreateSilent – it creates database, but before creation it checks if database exists. When true do nothing.
- Exists – checks if database exists
During creation of database connection string cannot contain database name so library removes it from the connection string if provided. From connection string:
Library will make and use
Database object implement IDatabase interface, so you can inject it or use it in tests if required.
Usage example
Database database = new Database(name, "Server=.\\SQL2019;Trusted_Connection=True;"); database.Create();
