DotNetBrightener.DataAccess.DataMigration
2025.0.2-preview-277
dotnet add package DotNetBrightener.DataAccess.DataMigration --version 2025.0.2-preview-277
NuGet\Install-Package DotNetBrightener.DataAccess.DataMigration -Version 2025.0.2-preview-277
<PackageReference Include="DotNetBrightener.DataAccess.DataMigration" Version="2025.0.2-preview-277" />
paket add DotNetBrightener.DataAccess.DataMigration --version 2025.0.2-preview-277
#r "nuget: DotNetBrightener.DataAccess.DataMigration, 2025.0.2-preview-277"
// Install DotNetBrightener.DataAccess.DataMigration as a Cake Addin #addin nuget:?package=DotNetBrightener.DataAccess.DataMigration&version=2025.0.2-preview-277&prerelease // Install DotNetBrightener.DataAccess.DataMigration as a Cake Tool #tool nuget:?package=DotNetBrightener.DataAccess.DataMigration&version=2025.0.2-preview-277&prerelease
Data Migration Library for .NET Core Applications
© 2024 DotNet Brightener
Versions
Package | Version |
---|---|
DotNetBrightener.DataAccess.DataMigration | |
DotNetBrightener.DataAccess.DataMigration.Mssql | |
DotNetBrightener.DataAccess.DataMigration.PostgreSql | |
dotnet-dnb-datamigration |
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
-
net9.0
- linq2db.EntityFrameworkCore (>= 9.0.0)
- Microsoft.EntityFrameworkCore (>= 9.0.0)
- Microsoft.EntityFrameworkCore.Proxies (>= 9.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
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.