SqlServerAliases.

ExecuteSqlFile(ICakeContext, string, FilePath) Method

Summary

Reads SQL commands from a file and executes them.
Assembly
Cake.SqlServer.dll
Namespace
Cake.SqlServer
Containing Type
SqlServerAliases

Syntax

public static void ExecuteSqlFile(this ICakeContext context, string connectionString, FilePath sqlFile)

Examples

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

    Task("Sql-Operations")
        .Does(() =>
        {
            var connectionString = @"Data Source=(localdb)\MSSqlLocalDb;Initial Catalog=MyDatabase";
            var sqlFile = "./somePath/MyScript.sql";
            ExecuteSqlCommand(connectionString, sqlFile);
        });

Attributes

Type Description
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext The Cake context.
connectionString string The connection string. You may want to specify Initial Catalog. If there are changing parameters, Microsoft.Data.SqlClient.SqlConnectionStringBuilder is recommended to escape input.
sqlFile FilePath Path to a file with SQL commands.

Return Value

Type Description
void