SPManager.NET 1.0.5

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

SPManager

SPManager is a .NET 9 library for versioning and managing SQL Server stored procedures with change detection, migration management, and a web dashboard.

Features

  • Versioning: Track stored procedure changes with full history tracking in the database
  • Change Detection: Compare stored procedures in a folder to those in a SQL Server database to detect additions, modifications, and deletions
  • Migration Management: Apply and rollback stored procedures with complete history
  • Dashboard Interface: View and manage stored procedures through a simple web dashboard
  • Automatic Startup Application: Optionally apply all detected changes automatically on application startup

Installation

Install the NuGet package:

dotnet add package SPManager

Quick Start

1. Create a Folder for Stored Procedures

Create a folder in your project to store your stored procedure SQL files:

/StoredProcedures
    ├── usp_GetUser.sql
    ├── usp_UpdateUser.sql
    └── usp_DeleteUser.sql

2. Register Services

In your Program.cs or Startup.cs file, register SPManager services:

// Add SPManager services
builder.Services.AddSPManager(options =>
{
    options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))
           .UseStoredProceduresFolder("StoredProcedures")
           .AutoApplyChangesOnStartup(true); // Optional: automatically apply changes on startup
});

3. Add the Dashboard

In your middleware configuration:

// Add SPManager dashboard
app.UseSPManagerDashboard(); // The dashboard is always available at "/spmanager"

4. Access the Dashboard

Navigate to /spmanager in your browser to access the dashboard.

Usage

Stored Procedure File Format

Create SQL files following standard naming conventions:

For example:

  • usp_GetUser.sql
  • usp_GetEmployee.sql

The content of each file should be a valid SQL script that creates or alters a stored procedure.

Dashboard Features

The dashboard provides three main tabs:

  1. Stored Procedures: View all stored procedures found in your configured folder
  2. Changes: View detected changes between folder and database
  3. History: View all stored procedures applied to the database with their version history

Actions available:

  • Apply a specific stored procedure
  • Apply all detected changes
  • Roll back to a previous version

Programmatic Usage

You can also use SPManager services directly in your code:

public class YourService
{
    private readonly ISPChangeDetector _changeDetector;
    private readonly ISPFileScanner _fileScanner;
    private readonly ISPDatabaseManager _databaseManager;

    public YourService(
        ISPChangeDetector changeDetector,
        ISPFileScanner fileScanner,
        ISPDatabaseManager databaseManager)
    {
        _changeDetector = changeDetector;
        _fileScanner = fileScanner;
        _databaseManager = databaseManager;
    }

    public async Task DoSomethingAsync()
    {
        // Get all stored procedures from folder
        var procedures = await _fileScanner.ScanFolderAsync();

        // Detect changes
        var changes = await _changeDetector.DetectChangesAsync();

        // Apply all changes
        await _changeDetector.ApplyAllChangesAsync();

        // Get stored procedure history
        var history = await _databaseManager.GetStoredProcedureHistoryAsync("usp_GetUser");

        // Apply a specific stored procedure
        var procedure = await _fileScanner.GetStoredProcedureAsync("usp_GetUser");
        if (procedure != null)
        {
            await _databaseManager.ApplyStoredProcedureAsync(procedure);
        }

        // Roll back to a previous version
        await _databaseManager.RollbackToVersionAsync("usp_GetUser", 1);
    }
}

License

This library is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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.5 110 5/30/2025
1.0.4 110 5/30/2025
1.0.3 113 5/30/2025
1.0.1 117 5/30/2025
1.0.0 118 5/30/2025