Pre-requisites
- .NET Core 3.0+ SDK
- SQL Server or Azure SQL Database
- Docker Client, if you choose SQL Server on Container
Prepare your database
Deploy an SQL Server on Linux container or use your preferred instance.
docker run -d -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=P@ssw0rd!" -p 1400:1433 -d mcr.microsoft.com/mssql/server:2017-latest
Run migration from .NET Core console app
Create new web app.
dotnet --version
3.0.100
dotnet new console -o console-sample
cd console-sample
Add Yuniql.AspNetCore
.
dotnet add package Yuniql.Core
dotnet build
Copy sample database into _db
directory in your project.
git clone https://github.com/rdagumampan/yuniql.git c:\temp\yuniql
cd c:\temp\yuniql\samples\basic-sqlserver-sample
Modify the Main
method of Program.cs
.
using Yuniql.Core;
...
...
static void Main(string[] args)
{
//create custom trace message sinks, this can be your own logger framework
var traceService = new ConsoleTraceService { IsDebugEnabled = true };
//configure your migration run
var configuration = Configuration.Instance;
configuration.Platform = "sqlserver";
configuration.Workspace = Path.Combine(Environment.CurrentDirectory, "_db");
configuration.ConnectionString = "Server=localhost,1400;Database=helloyuniql;User Id=SA;Password=P@ssw0rd!";
configuration.IsAutoCreateDatabase = true;
//run migrations
var migrationServiceFactory = new MigrationServiceFactory(traceService);
var migrationService = migrationServiceFactory.Create();
migrationService.Run();
}
Test .
dotnet build
dotnet run --debug
A working sample is available here for your reference https://github.com/rdagumampan/yuniql/tree/master/samples/sqlserver-console-sample.
Learn further
- Migrate via ASP.NET Core
- Migrate via Azure DevOps
- Migrate via Docker Container
- Yuniql CLI Command Reference
- Bulk Import CSV Master Data
- Use Token Replacement
- Environment-aware Migration
Found bugs?
Help us improve further please create an issue.