Summary
Creates a new EfMigrator for use in EF6 code-first migrations.
Syntax
[CakeMethodAlias]
public static IEfMigrator CreateEfMigrator(this ICakeContext context, EfMigratorSettings settings)
Examples
var migrationSettings = new EfMigratorSettings
{
AssemblyPath = @"path/to/example.data.dll",
ConfigurationClass = "Example.Migrations.Configuation",
AppConfigPath = @"path/to/example.data.dll.config",
ConnectionString = "Server=(localdb)\MSSQLLocalDB;Database=SchoolDb;User ID=sa;Password=Password12!",
ConnectionProvider = "System.Data.SqlClient"
};
Task("Migrate-To_Latest")
.Description("Migrate database to latest.")
.Does(() =>
{
using (var migrator = CreateEfMigrator(migrationSettings))
{
migrator.MigrateToLatest();
migrator.Commit();
}
});
Task("Generate-Script-To_Latest")
.Description("Generates a script to latest migration.")
.Does(() =>
{
using (var migrator = CreateEfMigrator(migrationSettings))
{
var script = migrator.GenerateScriptForLatest();
Information(script);
}
});
Attributes
Type |
Description |
CakeMethodAlias |
|
Parameters
Return Value