protected void Execute( Action <ModelBuilder> buildCommonAction, Action <ModelBuilder> buildSourceAction, Action <ModelBuilder> buildTargetAction, Action <IReadOnlyList <MigrationOperation> > assertActionUp, Action <IReadOnlyList <MigrationOperation> > assertActionDown, Action <DbContextOptionsBuilder> builderOptionsAction, bool skipSourceConventions = false) { var sourceModelBuilder = CreateModelBuilder(skipSourceConventions); buildCommonAction(sourceModelBuilder); buildSourceAction(sourceModelBuilder); var sourceModel = sourceModelBuilder.FinalizeModel(); var sourceOptionsBuilder = TestHelpers .AddProviderOptions(new DbContextOptionsBuilder()) .UseModel(sourceModel) .EnableSensitiveDataLogging(); var targetModelBuilder = CreateModelBuilder(skipConventions: false); buildCommonAction(targetModelBuilder); buildTargetAction(targetModelBuilder); var targetModel = targetModelBuilder.FinalizeModel(); var targetOptionsBuilder = TestHelpers .AddProviderOptions(new DbContextOptionsBuilder()) .UseModel(targetModel) .EnableSensitiveDataLogging(); if (builderOptionsAction != null) { builderOptionsAction(sourceOptionsBuilder); builderOptionsAction(targetOptionsBuilder); } var modelDiffer = CreateModelDiffer(targetOptionsBuilder.Options); var operationsUp = modelDiffer.GetDifferences(sourceModel.GetRelationalModel(), targetModel.GetRelationalModel()); assertActionUp(operationsUp); if (assertActionDown != null) { modelDiffer = CreateModelDiffer(sourceOptionsBuilder.Options); var operationsDown = modelDiffer.GetDifferences(targetModel.GetRelationalModel(), sourceModel.GetRelationalModel()); assertActionDown(operationsDown); } var noopOperations = modelDiffer.GetDifferences(sourceModel.GetRelationalModel(), sourceModel.GetRelationalModel()); Assert.Empty(noopOperations); noopOperations = modelDiffer.GetDifferences(targetModel.GetRelationalModel(), targetModel.GetRelationalModel()); Assert.Empty(noopOperations); }
protected void Execute( Action <ModelBuilder> buildCommonAction, Action <ModelBuilder> buildSourceAction, Action <ModelBuilder> buildTargetAction, Action <IReadOnlyList <MigrationOperation> > assertActionUp, Action <IReadOnlyList <MigrationOperation> > assertActionDown, Action <DbContextOptionsBuilder> builderOptionsAction) { var sourceModelBuilder = CreateModelBuilder(); buildCommonAction(sourceModelBuilder); buildSourceAction(sourceModelBuilder); sourceModelBuilder.FinalizeModel(); var sourceOptionsBuilder = TestHelpers .AddProviderOptions(new DbContextOptionsBuilder()) .UseModel(sourceModelBuilder.Model) .EnableSensitiveDataLogging(); var targetModelBuilder = CreateModelBuilder(); buildCommonAction(targetModelBuilder); buildTargetAction(targetModelBuilder); targetModelBuilder.FinalizeModel(); var targetOptionsBuilder = TestHelpers .AddProviderOptions(new DbContextOptionsBuilder()) .UseModel(targetModelBuilder.Model) .EnableSensitiveDataLogging(); if (builderOptionsAction != null) { builderOptionsAction(sourceOptionsBuilder); builderOptionsAction(targetOptionsBuilder); } var modelDiffer = CreateModelDiffer(targetOptionsBuilder.Options); var operationsUp = modelDiffer.GetDifferences(sourceModelBuilder.Model, targetModelBuilder.Model); assertActionUp(operationsUp); if (assertActionDown != null) { modelDiffer = CreateModelDiffer(sourceOptionsBuilder.Options); var operationsDown = modelDiffer.GetDifferences(targetModelBuilder.Model, sourceModelBuilder.Model); assertActionDown(operationsDown); } }