Cake build aliases for manipulating SQL Server databases and executing inline SQL and script files.
#addin nuget:?package=Cake.SqlServer&version=3.0.0
dotnet add package Cake.SqlServer --version 3.0.0
<PackageReference Include="Cake.SqlServer" Version="3.0.0" />
Aliases
Contains functionality to deal with DAC functionality from SQL Server: create and restore BACPAC files;
create and restore DACPAC files
General
BackupDatabase |
Backup an existing database to a file. |
CreateBacpacFile |
Creates a bacpac file for easy database backuping. |
CreateDatabase |
Creates an empty database. If database with this name already exists, throws a SqlException. Allows to specify primary and log files location. |
CreateDatabase |
Creates an empty database. If database with this name already exists, throws a SqlException.
Cake.SqlServer.SqlServerAliases.CreateDatabaseIfNotExists(Cake.Core.ICakeContext,System.String,System.String) if you would like to check if database already exists.
|
Create |
Creates an empty database if another database with the same does not already exist. |
Create |
Creates an empty database if another database with the same does not already exist. |
DatabaseExists |
Test if the database exists |
Drop |
First drops, then recreates the database |
Drop |
First drops, then recreates the database |
DropDatabase |
Drops database. Before dropping the DB, database is set to be offline, then online again. This is to be sure that there are no live connections, otherwise the script will fail. Also if the database does not exist - it will not do anything. |
ExecuteSqlCommand |
Execute any SQL command. |
ExecuteSqlCommand |
Execute any SQL command. |
ExecuteSqlFile |
Reads SQL commands from a file and executes them. |
ExecuteSqlFile |
Reads SQL commands from a file and executes them. |
ExtractDacpacFile |
Extracts a dacpac file to a database package. |
Local |
Creates a server instance and starts the server. |
Local |
Creates a server instance and starts the server. The version number defaults to the version of the SqlLocalDB utility |
Local |
Deletes the LocalDB instance |
LocalDbStartInstance |
Starts the LocalDB instance. Instance must exist before you can start it. |
LocalDbStopInstance |
Stops the LocalDB instance. |
OpenSqlConnection |
Opens a new Microsoft.Data.SqlClient.SqlConnection with the given connection string.
|
PublishDacpacFile |
Publish a dacpac file to a database. |
RestoreBacpac |
Restores a bacpac file into a database.
NB: there must be no database with the name you provide. Otherwise exception will be thrown. |
Restore |
Restores a database from multiple backup files. |
RestoreSqlBackup |
Restores a database from a backup file. |
RestoreSqlBackup |
Restores a database from a backup file. |
SetSqlCommandTimeout |
Sets the CommandTimeout property for all SqlCommands used internally |