DotNetBrightener.DataAccess.DataMigration 2024.0.14.5

dotnet add package DotNetBrightener.DataAccess.DataMigration --version 2024.0.14.5
NuGet\Install-Package DotNetBrightener.DataAccess.DataMigration -Version 2024.0.14.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="DotNetBrightener.DataAccess.DataMigration" Version="2024.0.14.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetBrightener.DataAccess.DataMigration --version 2024.0.14.5
#r "nuget: DotNetBrightener.DataAccess.DataMigration, 2024.0.14.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.
// Install DotNetBrightener.DataAccess.DataMigration as a Cake Addin
#addin nuget:?package=DotNetBrightener.DataAccess.DataMigration&version=2024.0.14.5

// Install DotNetBrightener.DataAccess.DataMigration as a Cake Tool
#tool nuget:?package=DotNetBrightener.DataAccess.DataMigration&version=2024.0.14.5

Data Migration Library for .NET Core Applications

© 2024 DotNet Brightener

Versions

Package Version
DotNetBrightener.DataAccess.DataMigration NuGet Version
DotNetBrightener.DataAccess.DataMigration.Mssql NuGet Version
DotNetBrightener.DataAccess.DataMigration.PostgreSql NuGet Version
dotnet-dnb-datamigration NuGet Version

Overview

Data Migration Library is a simple library to help you manage your data migration in your .NET Core application. It provides a simple way to define your migration classes and run them in your application.

Not all applications can use DACPAC for managing database schema and data changes. Especially DACPAC does not work with other databases such as MySQL, PostgreSQL, etc. This library is designed to help you manage your data migration in your application.

Installation

Install using Package Reference

dotnet add [YOUR_PROJECT_NAME] package DotNetBrightener.DataAccess.DataMigration

If you need to data migration with SQL Server, install the following package: DotNetBrightener.DataAccess.DataMigration.Mssql

dotnet add [YOUR_PROJECT_NAME] package DotNetBrightener.DataAccess.DataMigration.Mssql

For PostgreSQL, install the following package: DotNetBrightener.DataAccess.DataMigration.PostgreSql

dotnet add [YOUR_PROJECT_NAME] package DotNetBrightener.DataAccess.DataMigration.PostgreSql

Usage

Register to Service Collection
// var _connectionString = "<your_connection_string>";

// If you use SQL Server
services.EnableDataMigrations()
        .UseSqlServer(_connectionString);

// If you use PostgreSQL
services.EnableDataMigrations()
        .UseNpgsql(_connectionString);

// if you want to auto detect all migration classes
services.AutoScanDataMigrators();

// if you want to manually register migration classes
services.AddDataMigrator<MyMigration>();

Define your migration classes

using DotNetBrightener.DataAccess.DataMigration;

[DataMigration("<your_migration_id>")]
public class MyMigration : IDataMigration
{
    // You can use Dependency Injection for injecting your services
    private readonly IMyService _myService;

    public MyMigration(IMyService myService)
    {
        _myService = myService;
    }

    public async Task MigrateData()
    {
        // Your migration code here
        await _myService.DoSomethingToMigrateData();
    }
}

Roadmap

  • Initial Release
  • Add Support for SQL Server
  • Add Support for PostgreSQL
  • CLI tool for creating migration class

CLI Tool

You can now install the cli tool from Nuget: dotnet-dnb-datamigration

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DotNetBrightener.DataAccess.DataMigration:

Package Downloads
DotNetBrightener.DataAccess.DataMigration.Mssql

Package Description

DotNetBrightener.DataAccess.DataMigration.PostgreSql

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.