This content is part of a third party extension that is not supported by the Cake project.
For more information about this extension see
Cake.SqlServer.
Summary
First drops, then recreates the database
Syntax
public static void DropAndCreateDatabase(this ICakeContext context, string connectionString, string databaseName, CreateDatabaseSettings settings)
Examples
#addin "nuget:?package=Cake.SqlServer"
Task("ReCreate-Database")
.Does(() =>
{
var connectionString = @"Server=(localdb)\MSSqlLocalDb";
var dbName = "CakeTest";
var createSettings = new CreateDatabaseSettings()
.WithPrimaryFile(@"C:\MyPath\DB\CakeTest.mdf")
.WithLogFile(@"C:\MyPath\DB\CakeTest.ldf");
DropAndCreateDatabase(connectionString, dbName, createSettings);
});
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 to be dropped and re-created |
settings |
CreateDatabaseSettings |
Settings object with parameters |
Return Value