SqlServerAliases.

DropDatabase(ICakeContext, string, string) Method

Summary

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.
Assembly
Cake.SqlServer.dll
Namespace
Cake.SqlServer
Containing Type
SqlServerAliases

Syntax

public static void DropDatabase(this ICakeContext context, string connectionString, string databaseName)

Examples

    #addin "nuget:?package=Cake.SqlServer"

    Task("Drop-Database")
         .Does(() =>
         {
            var connectionString = @"Server=(localdb)\MSSqlLocalDb";
            var dbName = "CakeTest";
            DropDatabase(connectionString, dbName);
        });

Attributes

Type Description
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext The Cake context.
connectionString string The connection string. For this operation, it is recommended to connect to the master database (default). If there are changing parameters, Microsoft.Data.SqlClient.SqlConnectionStringBuilder is recommended to escape input.
databaseName string Database name to be dropped

Return Value

Type Description
void