ProductivityTools.DbUp 0.0.9

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

<p align="right"> <a href="https://www.powershellgallery.com/packages/ProductivityTools.ConvertTcx2Gpx/"><img src="Images/Header/Powershell_border_40px.png" /></a> <a href="http://productivitytools.tech/convert-tcx-to-gpx/"><img src="Images/Header/ProductivityTools_green_40px_2.png" /><a> <a href="https://github.com/pwujczyk/ProductivityTools.ConvertTcx2Gpx"><img src="Images/Header/Github_border_40px.png" /></a> </p> <p align="center"> <a href="http://productivitytools.tech/"> <img src="Images/Header/LogoTitle_green_500px.png" /> </a> </p>

DbUp

DbUp is a package which manages database updates. ProductivityTools DbUp package adds additional functionality to base DbUp like creating the database and creating log table.

I like to use it as in the DbUp I need to provide whole connection string and here only server name and database name.

To use it please reference package with the package manager console

Install-Package ProductivityTools.DbUp

Next create Console application and in the main add following code:

string serverName = "ServerName";
string dbName = "DatabaseName";
DBUpHelper.DBUp dBUp = new DBUpHelper.DBUp("gc");
Assembly assembly = Assembly.GetExecutingAssembly();
dBUp.PerformUpdate(serverName, dbName, assembly, false)

Next add Scripts Folder and create inside SQL scripts which you want to execute. In the properties of the script please select Embeded resource

When application will start, DBUpHelper will:

  • Check if database "DatabaseName" exists if not it will create it
  • In the database it will create schema provided in the constructor "gc"
  • It will start executing the scripts from the Script folder.

Original DbUp code

Those four lines above can are shorten version of the code from DbUp page

            var connectionString = "Server=.\\SQL2019;Database=PTTeamManagment;Trusted_connection=true";
            EnsureDatabase.For.SqlDatabase(connectionString);
            var upgrader =
                DeployChanges.To
                    .SqlDatabase(connectionString)
                    .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
                    .LogToConsole()
                    .Build();

            var result = upgrader.PerformUpgrade();

            if (!result.Successful)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(result.Error);
                Console.ResetColor();
#if DEBUG
                Console.ReadLine();
#endif
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Success!");
            Console.ResetColor();

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. 
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
0.0.9 132 17 days ago
0.0.8 129 17 days ago
0.0.7 950 6/1/2021
0.0.3 1,252 4/15/2019
0.0.2 1,044 1/22/2019