- add support for .net 10
- add support for .net 9 and removed the not supported .net versions
- is AOT compatible
Note: from version 4.0.2 on EasyDBMigrator will not use the Fluent Assertions package for internal testing. The reason is that Fluent Assertions is a commercial product now. EasyDBMigrator will only use non-commercial open source software.
Note: EasyDBMigrator is tested with MSTest on Microsoft.Testing.Platform. This is an internal testing choice only - it puts no constraint on the test framework you use in your own project.
- add support for .net 8
- monthly updates of all packages for stability and security
- add support for .net 7
- monthly update of all packages for stability and security
EasyDBMigrator is an open-source database migration framework. It strongly favors simplicity and ease of use for automatic CI/CD strategies, integration testing scenarios and easy integration in your own code.
- Make it easy to integrate Microsoft SQL migrations in your CI/CD flows
- Make it easy to integrate PostgreSQL migrations in your CI/CD flows
- Make it easy to perform manual Microsoft SQL migrations
- Make it easy to perform manual PostgreSQL migrations
- Make it easy to integrate this package into your own code/tool
- Provide examples of how to write unit and integration tests (feel free to give me code feedback or for a good discussion on testing)
The example below uses MSTest, which is what EasyDBMigrator itself is tested
with. EasyDBMigrator only depends on ILogger, so any test framework works
just as well.
[TestClass]
public class DatabaseTests
{
// MSTest injects this; it gives you the per-test cancellation token.
public TestContext TestContext { get; set; }
[TestMethod]
[TestCategory("IntegrationTest")]
public async Task RunMigrations()
{
// Make sure you use the correct naming in your scripts, like:
// 20210926_001_AddEquipmentTable.sql --> scripts are ordered by date
// and then per sequence number. In this case, '001' is the sequence
// number. Make sure to set the BUILD-ACTION property of every
// migration SQL script to EMBEDDED RESOURCE.
const string databaseName = "WorkoutIntegrationTests";
// Make sure that the 'Database = xxxx;' parameter is excluded in the
// connection-string.
const string connectionString =
"some fancy connectionstring without database param";
MigrationConfiguration config = new(connectionString: connectionString
, databaseName: databaseName);
// For writing the logging output from EasyDBMigrator to the test
// output window.
ILogger<DbMigrator> logger = LoggerFactory
.Create(builder => builder.AddDebug())
.CreateLogger<DbMigrator>();
Mock<IDateTimeHelper> dateTimeHelperMock = new();
// Can also use the PostgreSqlConnector to connect to PostgreSQL
// instead of Microsoft SQL Server.
DbMigrator migrator = DbMigrator.CreateForLocalIntegrationTesting(
migrationConfiguration: config
, logger: logger
, dataTimeHelperMock: dateTimeHelperMock.Object
, databaseConnector: new MicrosoftSqlConnector());
bool succeededDeletingDatabase =
await migrator.TryDeleteDatabaseIfExistAsync(
migrationConfiguration: config
, cancellationToken: TestContext.CancellationToken);
Assert.IsTrue(succeededDeletingDatabase);
bool succeededRunningMigrations =
await migrator.TryApplyMigrationsAsync(
typeOfClassWhereScriptsAreLocated:
typeof(HereTheSqlServerScriptsCanBeFound)
, migrationConfiguration: config
, cancellationToken: TestContext.CancellationToken);
Assert.IsTrue(succeededRunningMigrations);
// Download the code if you want to see more examples of integration
// testing with EasyDBMigrator.
}
}Free to use