Skip to content

Commit

Permalink
feat: add UseExtendedSqlServerMigrations()
Browse files Browse the repository at this point in the history
  • Loading branch information
CumpsD committed Aug 28, 2019
1 parent d439301 commit e6e7cff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.MigrationExtensions
namespace Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.MigrationExtensions
{
using System.Collections.Generic;
using System.Linq;
Expand All @@ -20,4 +20,4 @@ public override IEnumerable<IAnnotation> For(IIndex index)
return baseAnnotations.Concat(customAnnotations);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.MigrationExtensions
{
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;

public static class ExtendedSqlServerMigrationsExtensions
{
public static DbContextOptionsBuilder UseExtendedSqlServerMigrations(this DbContextOptionsBuilder optionsBuilder) =>
optionsBuilder
.ReplaceService<IMigrationsSqlGenerator, ExtendedSqlServerMigrationsSqlGenerator>()
.ReplaceService<IMigrationsAnnotationProvider, ExtendedSqlServerMigrationsAnnotationProvider>();

public static DbContextOptionsBuilder<T> UseExtendedSqlServerMigrations<T>(this DbContextOptionsBuilder<T> optionsBuilder) where T : DbContext =>
optionsBuilder
.ReplaceService<IMigrationsSqlGenerator, ExtendedSqlServerMigrationsSqlGenerator>()
.ReplaceService<IMigrationsAnnotationProvider, ExtendedSqlServerMigrationsAnnotationProvider>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using MigrationExtensions;

public interface IRunnerDbContextMigratorFactory
{
Expand Down Expand Up @@ -75,7 +76,8 @@ private DbContextOptionsBuilder<TContext> CreateOptionsBuilder(IConfiguration co
ConfigureSqlServerOptions(sqlServerOptions);
}
);
)
.UseExtendedSqlServerMigrations();

ConfigureOptionsBuilder(optionsBuilder);

Expand Down

0 comments on commit e6e7cff

Please sign in to comment.