VersionNext 1.0.1

dotnet add package VersionNext --version 1.0.1
                    
NuGet\Install-Package VersionNext -Version 1.0.1
                    
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="VersionNext" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VersionNext" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="VersionNext" />
                    
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 VersionNext --version 1.0.1
                    
#r "nuget: VersionNext, 1.0.1"
                    
#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 VersionNext@1.0.1
                    
#: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=VersionNext&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=VersionNext&version=1.0.1
                    
Install as a Cake Tool

VersionNext

VersionNext

VersionNext is a powerful and flexible database upgrade manager for SQL Server. Created by Nick Hadder, this NuGet package simplifies database deployment, version management, and upgrading to the latest development version for seamless development and production workflows.

Features

  • Automated Database Deployment: Easily deploy new databases with structured version control.
  • Version-Based Upgrades: Upgrade databases incrementally with defined schema and data migrations.
  • Development Mode Support: Upgrade to the latest development version for testing new changes.
  • Customizable Settings: Configure upgrade behaviors like rollback, SQL timeout, and version tracking.
  • SQL Server Support: Works with Microsoft SQL Server, leveraging Microsoft.Data.Sqlclient for database interactions.

Installation

Install VersionNext via NuGet:

PM> Install-Package VersionNext

Quick Start

1. Define Your Database Versions

Create the initial start of your database VersionStart.

public class InitialDatabaseCreation : Models.VersionStart
{
    public InitialDatabaseCreation() : base()
    {
        AddSqlUpdate("CREATE TABLE [dbo].[InitialTable] (Id INT Identity(1,1) PRIMARY KEY);");
    }
}

Create a release version DatabaseVersion.

public class v20250225 : DatabaseVersion
{
    public v20250225() : base(2025, 2, 25)
    {
        AddSqlUpdate("CREATE TABLE [dbo].[TestTable] ([Id] INT PRIMARY KEY);");
        AddSqlUpdate("INSERT INTO [dbo].[TestTable] ([Id]) VALUES (1);");
    }
}

Create the latest development version of your database VersionNext.

public class InitialDatabaseCreation : Models.VersionNext
{
    public class vDevelop : Models.VersionNext
    {
        public vDevelop() : base()
        {
            AddSqlUpdate("CREATE TABLE [dbo].[LatestTestTable] ([Id] INT PRIMARY KEY);");
        }
    }
}

2. Configure Database and Upgrade Settings

var connectionString = new SqlConnectionStringBuilder()
{
    DataSource = "localhost,1433",
    InitialCatalog = "MyDatabase",
    UserID = "sa",
    Password = "YourStrong!Passw0rd",
    TrustServerCertificate = true
};

var versions = new List<DatabaseVersion>()
{
    new InitialDatabaseCreation(), //initial database creation version (must be first)
    new v20250225(), //some released version where database upgrade was needed
    new vDevelop() //latest development version, yet to be released (must be last)
};

var database = new Database(connectionString, versions);

var settings = new DatabaseUpgraderSettings()
{
    ThrowOnUpgradeFailure = true,
    UpgradeVersionStart = true,
    UpgradeVersionNext = false,
    VersionTableSchema = "dbo",
    VersionTableName = "DatabaseVersion",
    SqlTimeoutSeconds = 60
};

3. Run Database Upgrades

var upgrader = new DatabaseUpgrader(database, settings);
await upgrader.UpgradeAsync();
var currentVersion = await upgrader.CurrentVersionAsync();
Console.WriteLine($"Database upgraded to version: {currentVersion.FullVersion}");

License

VersionNext is open-source and licensed under the MIT License.

Author

Nick Hadder - Creator of VersionNext

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve VersionNext.

Contact

For questions or feedback, reach out via GitHub Issues.


Happy upgrading! 🚀

There are no supported framework assets in this 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.1 93 2/26/2025
1.0.0 78 2/26/2025

Thank you for installing VersionNext