EffSln.DatabaseMigration 1.0.4

dotnet add package EffSln.DatabaseMigration --version 1.0.4
                    
NuGet\Install-Package EffSln.DatabaseMigration -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EffSln.DatabaseMigration" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EffSln.DatabaseMigration" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="EffSln.DatabaseMigration" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EffSln.DatabaseMigration --version 1.0.4
                    
#r "nuget: EffSln.DatabaseMigration, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EffSln.DatabaseMigration@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EffSln.DatabaseMigration&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=EffSln.DatabaseMigration&version=1.0.4
                    
Install as a Cake Tool

EffSln.DatabaseMigration

Automatic SQL script execution on startup. A companion to code first migrations to help deploy arbitrary sql scripts.

On every startup, all the scripts in the options.ScriptFolder are ran against the databases(s). Multiple destinations are supported.

Installation

dotnet add package EffSln.DatabaseMigration

Quick Start

// In Program.cs or Startup.cs
services.AddDatabaseMigration();

Configuration

Use DefaultConnection and data/procs folder

services.AddDatabaseMigration();

On multiple databases and specific different folder

services.AddDatabaseMigration(o =>
{
    o.ConnectionStringNames = new[] { "DefaultConnection", "SandboxConnection" };
    o.ScriptFolder = "scripts";
});

Additional Config

Run ef core code-first migrations (and run scripts) on multiple databases

services.AddDatabaseMigration(o =>
{
    o.ConnectionStringNames = new[] { "DefaultConnection", "SandboxConnection" };
    o.ScriptFolder = "data/procs";
    o.MigrateDbContext = async (services, connectionString) =>
    {
        var optionsBuilder = new DbContextOptionsBuilder<AppDbContext>()
            .UseNpgsql(connectionString);

        using var dbContext = new AppDbContext(optionsBuilder.Options);
        await dbContext.Database.MigrateAsync();
    };
});

Development

Build this repo in visual studio then you can reference it in another project like this:

Remove-Item -Recurse -Force "$env:USERPROFILE\.nuget\packages\EffSln.DatabaseMigration"
dotnet add package EffSln.DatabaseMigration --source C:\src\EffSln.DatabaseMigration\bin\Debug
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 198 10/2/2025
1.0.1 177 10/1/2025
1.0.0 180 10/1/2025