Example #1
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public Migrator(
            [NotNull] IMigrationsAssembly migrationsAssembly,
            [NotNull] IHistoryRepository historyRepository,
            [NotNull] IDatabaseCreator databaseCreator,
            [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] IMigrationCommandExecutor migrationCommandExecutor,
            [NotNull] IRelationalConnection connection,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] ILogger<Migrator> logger,
            [NotNull] IDatabaseProviderServices providerServices)
        {
            Check.NotNull(migrationsAssembly, nameof(migrationsAssembly));
            Check.NotNull(historyRepository, nameof(historyRepository));
            Check.NotNull(databaseCreator, nameof(databaseCreator));
            Check.NotNull(migrationsSqlGenerator, nameof(migrationsSqlGenerator));
            Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));
            Check.NotNull(migrationCommandExecutor, nameof(migrationCommandExecutor));
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(providerServices, nameof(providerServices));

            _migrationsAssembly = migrationsAssembly;
            _historyRepository = historyRepository;
            _databaseCreator = (IRelationalDatabaseCreator)databaseCreator;
            _migrationsSqlGenerator = migrationsSqlGenerator;
            _rawSqlCommandBuilder = rawSqlCommandBuilder;
            _migrationCommandExecutor = migrationCommandExecutor;
            _connection = connection;
            _sqlGenerationHelper = sqlGenerationHelper;
            _logger = logger;
            _activeProvider = providerServices.InvariantName;
        }
        public MigrationsScaffolder(
            [NotNull] DbContext context,
            [NotNull] IModel model,
            [NotNull] IMigrationsAssembly migrationsAssembly,
            [NotNull] IMigrationsModelDiffer modelDiffer,
            [NotNull] IMigrationsIdGenerator idGenerator,
            [NotNull] MigrationsCodeGenerator migrationCodeGenerator,
            [NotNull] IHistoryRepository historyRepository,
            [NotNull] ILoggerFactory loggerFactory,
            [NotNull] IDatabaseProviderServices providerServices)
        {
            Check.NotNull(context, nameof(context));
            Check.NotNull(model, nameof(model));
            Check.NotNull(migrationsAssembly, nameof(migrationsAssembly));
            Check.NotNull(modelDiffer, nameof(modelDiffer));
            Check.NotNull(idGenerator, nameof(idGenerator));
            Check.NotNull(migrationCodeGenerator, nameof(migrationCodeGenerator));
            Check.NotNull(historyRepository, nameof(historyRepository));
            Check.NotNull(loggerFactory, nameof(loggerFactory));
            Check.NotNull(providerServices, nameof(providerServices));

            _contextType = context.GetType();
            _model = model;
            _migrationsAssembly = migrationsAssembly;
            _modelDiffer = modelDiffer;
            _idGenerator = idGenerator;
            _migrationCodeGenerator = migrationCodeGenerator;
            _historyRepository = historyRepository;
            _logger = new LazyRef<ILogger>(() => loggerFactory.CreateCommandsLogger());
            _activeProvider = providerServices.InvariantName;
        }
Example #3
0
        public Migrator(
            [NotNull] IMigrationsAssembly migrationAssembly,
            [NotNull] IHistoryRepository historyRepository,
            [NotNull] IDatabaseCreator databaseCreator,
            [NotNull] IMigrationsSqlGenerator sqlGenerator,
            [NotNull] ISqlStatementExecutor executor,
            [NotNull] IRelationalConnection connection,
            [NotNull] IUpdateSqlGenerator sql,
            [NotNull] ILoggerFactory loggerFactory)
        {
            Check.NotNull(migrationAssembly, nameof(migrationAssembly));
            Check.NotNull(historyRepository, nameof(historyRepository));
            Check.NotNull(databaseCreator, nameof(databaseCreator));
            Check.NotNull(sqlGenerator, nameof(sqlGenerator));
            Check.NotNull(executor, nameof(executor));
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(sql, nameof(sql));
            Check.NotNull(loggerFactory, nameof(loggerFactory));

            _migrationAssembly = migrationAssembly;
            _historyRepository = historyRepository;
            _databaseCreator = (IRelationalDatabaseCreator)databaseCreator;
            _sqlGenerator = sqlGenerator;
            _executor = executor;
            _connection = connection;
            _sql = sql;
            _logger = new LazyRef<ILogger>(loggerFactory.CreateLogger<Migrator>);
        }
        public MigrationsScaffolderDependencies(
            [NotNull] ICurrentDbContext currentContext,
            [NotNull] IModel model,
            [NotNull] IMigrationsAssembly migrationsAssembly,
            [NotNull] IMigrationsModelDiffer migrationsModelDiffer,
            [NotNull] IMigrationsIdGenerator migrationsIdGenerator,
            [NotNull] IMigrationsCodeGeneratorSelector migrationsCodeGeneratorSelector,
            [NotNull] IHistoryRepository historyRepository,
            [NotNull] IOperationReporter operationReporter,
            [NotNull] IDatabaseProvider databaseProvider,
            [NotNull] ISnapshotModelProcessor snapshotModelProcessor,
            [NotNull] IMigrator migrator)
        {
            Check.NotNull(currentContext, nameof(currentContext));
            Check.NotNull(model, nameof(model));
            Check.NotNull(migrationsAssembly, nameof(migrationsAssembly));
            Check.NotNull(migrationsModelDiffer, nameof(migrationsModelDiffer));
            Check.NotNull(migrationsIdGenerator, nameof(migrationsIdGenerator));
            Check.NotNull(migrationsCodeGeneratorSelector, nameof(migrationsCodeGeneratorSelector));
            Check.NotNull(historyRepository, nameof(historyRepository));
            Check.NotNull(operationReporter, nameof(operationReporter));
            Check.NotNull(databaseProvider, nameof(databaseProvider));
            Check.NotNull(snapshotModelProcessor, nameof(snapshotModelProcessor));
            Check.NotNull(migrator, nameof(migrator));

            CurrentContext                  = currentContext;
            Model                           = model;
            MigrationsAssembly              = migrationsAssembly;
            MigrationsModelDiffer           = migrationsModelDiffer;
            MigrationsIdGenerator           = migrationsIdGenerator;
            MigrationsCodeGeneratorSelector = migrationsCodeGeneratorSelector;
            HistoryRepository               = historyRepository;
            OperationReporter               = operationReporter;
            DatabaseProvider                = databaseProvider;
            SnapshotModelProcessor          = snapshotModelProcessor;
            Migrator                        = migrator;
        }
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public Migrator(
            [NotNull] IMigrationsAssembly migrationsAssembly,
            [NotNull] IHistoryRepository historyRepository,
            [NotNull] IDatabaseCreator databaseCreator,
            [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] IMigrationCommandExecutor migrationCommandExecutor,
            [NotNull] IRelationalConnection connection,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Migrations> logger,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
            [NotNull] IDatabaseProvider databaseProvider)
        {
            Check.NotNull(migrationsAssembly, nameof(migrationsAssembly));
            Check.NotNull(historyRepository, nameof(historyRepository));
            Check.NotNull(databaseCreator, nameof(databaseCreator));
            Check.NotNull(migrationsSqlGenerator, nameof(migrationsSqlGenerator));
            Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));
            Check.NotNull(migrationCommandExecutor, nameof(migrationCommandExecutor));
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(commandLogger, nameof(commandLogger));
            Check.NotNull(databaseProvider, nameof(databaseProvider));

            _migrationsAssembly       = migrationsAssembly;
            _historyRepository        = historyRepository;
            _databaseCreator          = (IRelationalDatabaseCreator)databaseCreator;
            _migrationsSqlGenerator   = migrationsSqlGenerator;
            _rawSqlCommandBuilder     = rawSqlCommandBuilder;
            _migrationCommandExecutor = migrationCommandExecutor;
            _connection          = connection;
            _sqlGenerationHelper = sqlGenerationHelper;
            _logger         = logger;
            _commandLogger  = commandLogger;
            _activeProvider = databaseProvider.Name;
        }
 public MySqlMigrator(
     [NotNull] IMigrationsAssembly migrationsAssembly,
     [NotNull] IHistoryRepository historyRepository,
     [NotNull] IDatabaseCreator databaseCreator,
     [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
     [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
     [NotNull] IMigrationCommandExecutor migrationCommandExecutor,
     [NotNull] IRelationalConnection connection,
     [NotNull] ISqlGenerationHelper sqlGenerationHelper,
     [NotNull] ICurrentDbContext currentContext,
     [NotNull] IConventionSetBuilder conventionSetBuilder,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Migrations> logger,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
     [NotNull] IDatabaseProvider databaseProvider)
     : base(
         migrationsAssembly,
         historyRepository,
         databaseCreator,
         migrationsSqlGenerator,
         rawSqlCommandBuilder,
         migrationCommandExecutor,
         connection,
         sqlGenerationHelper,
         currentContext,
         conventionSetBuilder,
         logger,
         commandLogger,
         databaseProvider)
 {
     _migrationsAssembly   = migrationsAssembly;
     _historyRepository    = historyRepository;
     _rawSqlCommandBuilder = rawSqlCommandBuilder;
     _sqlGenerationHelper  = sqlGenerationHelper;
     _currentContext       = currentContext;
     _commandLogger        = commandLogger;
 }
Example #7
0
 public TestMigrationsAssembly()
 {
     Mock = new Mock <IMigrationsAssembly>();
     _migrationsAssembly = Mock.Object;
 }