Exemple #1
0
 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] IDiagnosticsLogger <DbLoggerCategory.Migrations> logger,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
     [NotNull] IDatabaseProvider databaseProvider)
     : base(
         migrationsAssembly,
         historyRepository,
         databaseCreator,
         migrationsSqlGenerator,
         rawSqlCommandBuilder,
         migrationCommandExecutor,
         connection,
         sqlGenerationHelper,
         currentContext,
         logger,
         commandLogger,
         databaseProvider)
 {
     _migrationsAssembly   = migrationsAssembly;
     _rawSqlCommandBuilder = rawSqlCommandBuilder;
     _currentContext       = currentContext;
     _commandLogger        = commandLogger;
 }
Exemple #2
0
        public Migrator(
            [NotNull] IMigrationsAssembly migrationsAssembly,
            [NotNull] IHistoryRepository historyRepository,
            [NotNull] IDatabaseCreator databaseCreator,
            [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [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(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;
            _connection             = connection;
            _sqlGenerationHelper    = sqlGenerationHelper;
            _logger         = logger;
            _activeProvider = providerServices.InvariantName;
        }
Exemple #3
0
 /// <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(
     IMigrationsAssembly migrationsAssembly,
     IHistoryRepository historyRepository,
     IDatabaseCreator databaseCreator,
     IMigrationsSqlGenerator migrationsSqlGenerator,
     IRawSqlCommandBuilder rawSqlCommandBuilder,
     IMigrationCommandExecutor migrationCommandExecutor,
     IRelationalConnection connection,
     ISqlGenerationHelper sqlGenerationHelper,
     ICurrentDbContext currentContext,
     IModelRuntimeInitializer modelRuntimeInitializer,
     IDiagnosticsLogger <DbLoggerCategory.Migrations> logger,
     IRelationalCommandDiagnosticsLogger commandLogger,
     IDatabaseProvider databaseProvider)
 {
     _migrationsAssembly       = migrationsAssembly;
     _historyRepository        = historyRepository;
     _databaseCreator          = (IRelationalDatabaseCreator)databaseCreator;
     _migrationsSqlGenerator   = migrationsSqlGenerator;
     _rawSqlCommandBuilder     = rawSqlCommandBuilder;
     _migrationCommandExecutor = migrationCommandExecutor;
     _connection              = connection;
     _sqlGenerationHelper     = sqlGenerationHelper;
     _currentContext          = currentContext;
     _modelRuntimeInitializer = modelRuntimeInitializer;
     _logger         = logger;
     _commandLogger  = commandLogger;
     _activeProvider = databaseProvider.Name;
 }
 public Servicos(IVeiculoDAO veiculoDao, ILojaDAO lojaDao,
                 IDatabaseCreator databaseCreator)
 {
     _veiculoDao = veiculoDao;
     _lojaDao = lojaDao;
     _databaseCreator = databaseCreator;
 }
Exemple #5
0
        internal CosmosStore(IDocumentClient documentClient,
                             string databaseName,
                             string authKey,
                             string endpoint,
                             string overriddenCollectionName,
                             IDatabaseCreator databaseCreator     = null,
                             ICollectionCreator collectionCreator = null,
                             bool scaleable = false)
        {
            CollectionName = overriddenCollectionName;
            DatabaseName   = databaseName;
            if (documentClient == null)
            {
                throw new ArgumentNullException(nameof(documentClient));
            }
            var cosmonautClient = new CosmonautClient(documentClient);

            Settings = new CosmosStoreSettings(databaseName, endpoint, authKey, documentClient.ConnectionPolicy,
                                               scaleCollectionRUsAutomatically: scaleable);
            if (string.IsNullOrEmpty(Settings.DatabaseName))
            {
                throw new ArgumentNullException(nameof(Settings.DatabaseName));
            }
            _collectionCreator = collectionCreator ?? new CosmosCollectionCreator(cosmonautClient);
            _databaseCreator   = databaseCreator ?? new CosmosDatabaseCreator(cosmonautClient);
            _cosmosScaler      = new CosmosScaler <TEntity>(this);
            InitialiseCosmosStore();
        }
Exemple #6
0
 public App(ILogger <App> log, IConfig config, IDatabaseCreator creator, IDatabaseMigrator migrator)
 {
     _log      = log;
     _config   = config;
     _creator  = creator;
     _migrator = migrator;
 }
Exemple #7
0
        private bool Copy(IDatabaseCreator dbCreator, DatabaseTable databaseTable)
        {
            Debug.WriteLine("Copying " + databaseTable.Name);
            var originSql      = new SqlWriter(databaseTable, _originType);
            var destinationSql = new SqlWriter(databaseTable, _destinationType);

            var selectAll = originSql.SelectAllSql();
            //SQLServerCE and SQLite can't deal with output parameters, so we can't use the standard INSERT.
            string insert = destinationSql.InsertSqlIncludingIdentity();

            //for sqlserver, we must also allow identity inserts (done in database inserter)

            using (var inserter = new DatabaseInserterFactory(_useSqlServerCe).CreateDatabaseInserter(dbCreator.CreateConnection(), insert, databaseTable))
            {
                using (var con = _dbFactory.CreateConnection())
                {
                    con.ConnectionString = _originConnection;
                    using (var cmd = con.CreateCommand())
                    {
                        cmd.CommandText = selectAll;
                        con.Open();
                        using (var rdr = cmd.ExecuteReader())
                        {
                            return(ReadRows(rdr, inserter, databaseTable, destinationSql));
                        }
                    }
                }
            }
        }
        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>);
        }
        /// <summary>
        ///     <para>
        ///         Creates the service dependencies parameter object for a <see cref="HistoryRepository" />.
        ///     </para>
        ///     <para>
        ///         Do not call this constructor directly from either provider or application code as it may change
        ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
        ///         will be created and injected automatically by the dependency injection container. To create
        ///         an instance with some dependent services replaced, first resolve the object from the dependency
        ///         injection container, then replace selected services using the 'With...' methods. Do not call
        ///         the constructor at any point in this process.
        ///     </para>
        ///     <para>
        ///         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.
        ///     </para>
        /// </summary>
        /// <param name="databaseCreator"> The database creator. </param>
        /// <param name="rawSqlCommandBuilder"> A command builder for building raw SQL commands. </param>
        /// <param name="connection"> The connection to the database. </param>
        /// <param name="options"> Options for the current context instance. </param>
        /// <param name="modelDiffer"> The model differ. </param>
        /// <param name="migrationsSqlGenerator"> The SQL generator for Migrations operations. </param>
        /// <param name="annotations"> Access to relational metadata for the model. </param>
        /// <param name="sqlGenerationHelper"> Helpers for generating update SQL. </param>
        public HistoryRepositoryDependencies(
            [NotNull] IDatabaseCreator databaseCreator,
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] IRelationalConnection connection,
            [NotNull] IDbContextOptions options,
            [NotNull] IMigrationsModelDiffer modelDiffer,
            [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
            [NotNull] IRelationalAnnotationProvider annotations,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper)
        {
            Check.NotNull(databaseCreator, nameof(databaseCreator));
            Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(options, nameof(options));
            Check.NotNull(modelDiffer, nameof(modelDiffer));
            Check.NotNull(migrationsSqlGenerator, nameof(migrationsSqlGenerator));
            Check.NotNull(annotations, nameof(annotations));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));

            DatabaseCreator      = (IRelationalDatabaseCreator)databaseCreator;
            RawSqlCommandBuilder = rawSqlCommandBuilder;
            Connection           = connection;
            Options                = options;
            ModelDiffer            = modelDiffer;
            MigrationsSqlGenerator = migrationsSqlGenerator;
            Annotations            = annotations;
            SqlGenerationHelper    = sqlGenerationHelper;
        }
Exemple #10
0
 public TrexActivator(IDatabaseCreator databaseCreator, IEmailService emailService, ITrexBaseContextProvider contextProvider, IAppSettings appSettings)
 {
     _databaseCreator = databaseCreator;
     _emailService    = emailService;
     _contextProvider = contextProvider;
     _appSettings     = appSettings;
 }
        /// <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] IInterceptingLogger <LoggerCategory.Migrations> logger,
            [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(databaseProvider, nameof(databaseProvider));

            _migrationsAssembly       = migrationsAssembly;
            _historyRepository        = historyRepository;
            _databaseCreator          = (IRelationalDatabaseCreator)databaseCreator;
            _migrationsSqlGenerator   = migrationsSqlGenerator;
            _rawSqlCommandBuilder     = rawSqlCommandBuilder;
            _migrationCommandExecutor = migrationCommandExecutor;
            _connection          = connection;
            _sqlGenerationHelper = sqlGenerationHelper;
            _logger         = logger;
            _activeProvider = databaseProvider.InvariantName;
        }
Exemple #12
0
 internal CosmosStore(ICosmonautClient cosmonautClient,
                      string databaseName,
                      string overriddenCollectionName,
                      IDatabaseCreator databaseCreator     = null,
                      ICollectionCreator collectionCreator = null,
                      bool scaleable = false)
 {
     CollectionName  = overriddenCollectionName;
     DatabaseName    = databaseName;
     CosmonautClient = cosmonautClient ?? throw new ArgumentNullException(nameof(cosmonautClient));
     Settings        = new CosmosStoreSettings(databaseName, cosmonautClient.DocumentClient.ServiceEndpoint.ToString(), string.Empty, cosmonautClient.DocumentClient.ConnectionPolicy,
                                               scaleCollectionRUsAutomatically: scaleable);
     if (Settings.InfiniteRetries)
     {
         CosmonautClient.DocumentClient.SetupInfiniteRetries();
     }
     if (string.IsNullOrEmpty(Settings.DatabaseName))
     {
         throw new ArgumentNullException(nameof(Settings.DatabaseName));
     }
     _collectionCreator = collectionCreator ?? new CosmosCollectionCreator(CosmonautClient);
     _databaseCreator   = databaseCreator ?? new CosmosDatabaseCreator(CosmonautClient);
     _cosmosScaler      = new CosmosScaler <TEntity>(this);
     InitialiseCosmosStore();
 }
 public static IServiceCollection AddCosmosStore <TEntity>(this IServiceCollection services,
                                                           IDocumentClient documentClient,
                                                           string databaseName,
                                                           IDatabaseCreator databaseCreator,
                                                           ICollectionCreator collectionCreator) where TEntity : class
 {
     services.AddSingleton <ICosmosStore <TEntity> >(x => new CosmosStore <TEntity>(documentClient, databaseName, databaseCreator, collectionCreator));
     return(services);
 }
 public HostConnectionViewModel(
     IConfigurationService configService,
     IEventAggregator events,
     [Import(CreatorNames.Sql)] IDatabaseCreator dbCreator)
 {
     ConfigurationService = configService;
     Events    = events;
     DbCreator = dbCreator;
     WireCommandsAndEvents();
 }
Exemple #15
0
 public IgnoreForeignKeyMySqlMigrator(IMigrationsAssembly migrationsAssembly,
                                      IHistoryRepository historyRepository,
                                      IDatabaseCreator databaseCreator, IMigrationsSqlGenerator migrationsSqlGenerator,
                                      IRawSqlCommandBuilder rawSqlCommandBuilder, IMigrationCommandExecutor migrationCommandExecutor,
                                      IRelationalConnection connection, ISqlGenerationHelper sqlGenerationHelper,
                                      ICurrentDbContext currentContext, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger,
                                      IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger, IDatabaseProvider databaseProvider) :
     base(migrationsAssembly, historyRepository, databaseCreator, migrationsSqlGenerator, rawSqlCommandBuilder,
          migrationCommandExecutor, connection, sqlGenerationHelper, currentContext, logger, commandLogger,
          databaseProvider)
 {
 }
Exemple #16
0
        protected HistoryRepository(
            [NotNull] IDatabaseCreator databaseCreator,
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] IRelationalConnection connection,
            [NotNull] IDbContextOptions options,
            [NotNull] IMigrationsModelDiffer modelDiffer,
            [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
            [NotNull] IRelationalAnnotationProvider annotations,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper)
        {
            Check.NotNull(databaseCreator, nameof(databaseCreator));
            Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(options, nameof(options));
            Check.NotNull(modelDiffer, nameof(modelDiffer));
            Check.NotNull(migrationsSqlGenerator, nameof(migrationsSqlGenerator));
            Check.NotNull(annotations, nameof(annotations));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));

            _databaseCreator        = (IRelationalDatabaseCreator)databaseCreator;
            _rawSqlCommandBuilder   = rawSqlCommandBuilder;
            _connection             = connection;
            _modelDiffer            = modelDiffer;
            _migrationsSqlGenerator = migrationsSqlGenerator;
            SqlGenerationHelper     = sqlGenerationHelper;

            var relationalOptions = RelationalOptionsExtension.Extract(options);

            TableName   = relationalOptions?.MigrationsHistoryTableName ?? DefaultTableName;
            TableSchema = relationalOptions.MigrationsHistoryTableSchema;
            _model      = new LazyRef <IModel>(
                () =>
            {
                var modelBuilder = new ModelBuilder(new ConventionSet());
                modelBuilder.Entity <HistoryRow>(
                    x =>
                {
                    ConfigureTable(x);
                    x.ToTable(TableName, TableSchema);
                });

                return(modelBuilder.Model);
            });
            var entityType = new LazyRef <IEntityType>(() => _model.Value.FindEntityType(typeof(HistoryRow)));

            _migrationIdColumnName = new LazyRef <string>(
                () => annotations.For(entityType.Value.FindProperty(nameof(HistoryRow.MigrationId))).ColumnName);
            _productVersionColumnName = new LazyRef <string>(
                () => annotations.For(entityType.Value.FindProperty(nameof(HistoryRow.ProductVersion))).ColumnName);
        }
Exemple #17
0
 public TemporalTableMigrator(
     IMigrationsAssembly migrationsAssembly,
     IHistoryRepository historyRepository,
     IDatabaseCreator databaseCreator,
     IMigrationsSqlGenerator migrationsSqlGenerator,
     IRawSqlCommandBuilder rawSqlCommandBuilder,
     IMigrationCommandExecutor migrationCommandExecutor,
     IRelationalConnection connection, ISqlGenerationHelper sqlGenerationHelper,
     IDiagnosticsLogger <DbLoggerCategory.Migrations> logger,
     IDatabaseProvider databaseProvider,
     ITemporalTableSqlExecutor <TContext> temporalTableSqlExecutor)
     : base(migrationsAssembly, historyRepository, databaseCreator, migrationsSqlGenerator, rawSqlCommandBuilder, migrationCommandExecutor, connection, sqlGenerationHelper, logger, databaseProvider)
 {
     this.temporalTableSqlExecutor = temporalTableSqlExecutor;
 }
Exemple #18
0
 internal CosmosStore(IDocumentClient documentClient,
                      string databaseName,
                      IDatabaseCreator databaseCreator,
                      ICollectionCreator collectionCreator)
 {
     DocumentClient = documentClient ?? throw new ArgumentNullException(nameof(documentClient));
     Settings       = new CosmosStoreSettings(databaseName, documentClient.ServiceEndpoint, documentClient.AuthKey.ToString(), documentClient.ConnectionPolicy);
     if (string.IsNullOrEmpty(Settings.DatabaseName))
     {
         throw new ArgumentNullException(nameof(Settings.DatabaseName));
     }
     _databaseCreator   = databaseCreator ?? throw new ArgumentNullException(nameof(databaseCreator));
     _collectionCreator = collectionCreator ?? throw new ArgumentNullException(nameof(collectionCreator));
     InitialiseCosmosStore();
 }
 /// <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 DatabaseFacadeDependencies(
     [NotNull] IDbContextTransactionManager transactionManager,
     [NotNull] IDatabaseCreator databaseCreator,
     [NotNull] IExecutionStrategyFactory executionStrategyFactory,
     [NotNull] IEnumerable <IDatabaseProvider> databaseProviders,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
     [NotNull] IConcurrencyDetector concurrencyDetector)
 {
     TransactionManager       = transactionManager;
     DatabaseCreator          = databaseCreator;
     ExecutionStrategyFactory = executionStrategyFactory;
     DatabaseProviders        = databaseProviders;
     CommandLogger            = commandLogger;
     ConcurrencyDetector      = concurrencyDetector;
 }
Exemple #20
0
        public CosmosStore(CosmosStoreSettings settings, string overriddenCollectionName)
        {
            Settings     = settings ?? throw new ArgumentNullException(nameof(settings));
            DatabaseName = settings.DatabaseName;
            var documentClient = DocumentClientFactory.CreateDocumentClient(settings);

            CosmonautClient = new CosmonautClient(documentClient, Settings.InfiniteRetries);
            if (string.IsNullOrEmpty(Settings.DatabaseName))
            {
                throw new ArgumentNullException(nameof(Settings.DatabaseName));
            }
            _collectionCreator = new CosmosCollectionCreator(CosmonautClient);
            _databaseCreator   = new CosmosDatabaseCreator(CosmonautClient);
            InitialiseCosmosStore(overriddenCollectionName);
        }
Exemple #21
0
 /// <summary>
 /// Creates a new instance of <see cref="DataMigrator"/>.
 /// </summary>
 public DataMigrator(
     IHistoryRepository historyRepository,
     IDatabaseCreator databaseCreator,
     IMigrationsSqlGenerator migrationsSqlGenerator,
     IRawSqlCommandBuilder rawSqlCommandBuilder,
     IRelationalConnection connection,
     ILoggerFactory loggerFactory,
     IServiceProvider serviceProvider)
 {
     _historyRepository = historyRepository;
     _databaseCreator = (IRelationalDatabaseCreator)databaseCreator;
     _migrationsSqlGenerator = migrationsSqlGenerator;
     _rawSqlCommandBuilder = rawSqlCommandBuilder;
     _connection = connection;
     _serviceProvider = serviceProvider;
     _logger = loggerFactory.CreateLogger<DataMigrator>();
 }
Exemple #22
0
        public CosmosStore(CosmosStoreSettings settings,
                           IDatabaseCreator databaseCreator,
                           ICollectionCreator collectionCreator)
        {
            Settings = settings ?? throw new ArgumentNullException(nameof(settings));
            var endpointUrl = Settings.EndpointUrl ?? throw new ArgumentNullException(nameof(Settings.EndpointUrl));
            var authKey     = Settings.AuthKey ?? throw new ArgumentNullException(nameof(Settings.AuthKey));

            DocumentClient = DocumentClientFactory.CreateDocumentClient(endpointUrl, authKey);
            if (string.IsNullOrEmpty(Settings.DatabaseName))
            {
                throw new ArgumentNullException(nameof(Settings.DatabaseName));
            }
            _collectionCreator = collectionCreator ?? throw new ArgumentNullException(nameof(collectionCreator));
            _databaseCreator   = databaseCreator ?? throw new ArgumentNullException(nameof(databaseCreator));
            InitialiseCosmosStore();
        }
Exemple #23
0
 public TemporalTableMigrator(
     IMigrationsAssembly migrationsAssembly,
     IHistoryRepository historyRepository,
     IDatabaseCreator databaseCreator,
     IEnumerable <IMigrationsSqlGenerator> migrationsSqlGenerators,
     IRawSqlCommandBuilder rawSqlCommandBuilder,
     IMigrationCommandExecutor migrationCommandExecutor,
     IRelationalConnection connection,
     ISqlGenerationHelper sqlGenerationHelper,
     ICurrentDbContext currentDbContext,
     IConventionSetBuilder conventionSetBuilder,
     IDiagnosticsLogger <DbLoggerCategory.Migrations> logger,
     IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
     IDatabaseProvider databaseProvider,
     ITemporalTableSqlExecutor <TContext> temporalTableSqlExecutor)
     : base(migrationsAssembly, historyRepository, databaseCreator, resolveMigrationsSqlGenerator(migrationsSqlGenerators), rawSqlCommandBuilder, migrationCommandExecutor, connection, sqlGenerationHelper, currentDbContext, conventionSetBuilder, logger, commandLogger, databaseProvider)
 {
     this.temporalTableSqlExecutor = temporalTableSqlExecutor;
 }
Exemple #24
0
        /// <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] ICurrentDbContext currentContext,
            [NotNull] IConventionSetBuilder conventionSetBuilder,
            [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(currentContext, nameof(currentContext));
            Check.NotNull(conventionSetBuilder, nameof(conventionSetBuilder));
            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;
            _currentContext       = currentContext;
            _conventionSetBuilder = conventionSetBuilder;
            _logger         = logger;
            _commandLogger  = commandLogger;
            _activeProvider = databaseProvider.Name;
        }
 public MySQLHistoryRepository(
     IDatabaseCreator databaseCreator,
     IRawSqlCommandBuilder sqlCommandBuilder,
     MySQLServerConnection connection,
     IDbContextOptions options,
     IMigrationsModelDiffer modelDiffer,
     MySQLMigrationsSqlGenerator sqlGenerator,
     IRelationalAnnotationProvider annotations,
     ISqlGenerationHelper sql)
     : base(
         databaseCreator,
         sqlCommandBuilder,
         connection,
         options,
         modelDiffer,
         sqlGenerator,
         annotations,
         sql)
 {
 }
 public MyHistoryRepository(
     IDatabaseCreator databaseCreator,
     IRawSqlCommandBuilder rawSqlCommandBuilder,
     IRelationalConnection connection,
     IDbContextOptions options,
     IMigrationsModelDiffer modelDiffer,
     IMigrationsSqlGenerator migrationsSqlGenerator,
     IRelationalAnnotationProvider annotations,
     ISqlGenerationHelper sqlGenerationHelper)
     : base(databaseCreator,
         rawSqlCommandBuilder,
         connection,
         options,
         modelDiffer,
         migrationsSqlGenerator,
         annotations,
         sqlGenerationHelper
         )
 {
 }
 /// <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 SqliteHistoryRepository(
     [NotNull] IDatabaseCreator databaseCreator,
     [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
     [NotNull] IRelationalConnection connection,
     [NotNull] IDbContextOptions options,
     [NotNull] IMigrationsModelDiffer modelDiffer,
     [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
     [NotNull] IRelationalAnnotationProvider annotations,
     [NotNull] ISqlGenerationHelper sqlGenerationHelper)
     : base(
         databaseCreator,
         rawSqlCommandBuilder,
         connection,
         options,
         modelDiffer,
         migrationsSqlGenerator,
         annotations,
         sqlGenerationHelper)
 {
 }
Exemple #28
0
 public SqlServerHistoryRepository(
     [NotNull] IDatabaseCreator databaseCreator,
     [NotNull] ISqlStatementExecutor executor,
     [NotNull] ISqlServerConnection connection,
     [NotNull] IDbContextOptions options,
     [NotNull] IMigrationsModelDiffer modelDiffer,
     [NotNull] SqlServerMigrationsSqlGenerator sqlGenerator,
     [NotNull] SqlServerMetadataExtensionProvider annotations,
     [NotNull] ISqlServerUpdateSqlGenerator sql)
     : base(
         databaseCreator,
         executor,
         connection,
         options,
         modelDiffer,
         sqlGenerator,
         annotations,
         sql)
 {
 }
Exemple #29
0
 /// <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 RelationalDatabaseFacadeDependencies(
     [NotNull] IDbContextTransactionManager transactionManager,
     [NotNull] IDatabaseCreator databaseCreator,
     [NotNull] IExecutionStrategyFactory executionStrategyFactory,
     [NotNull] IEnumerable <IDatabaseProvider> databaseProviders,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
     [NotNull] IConcurrencyDetector concurrencyDetector,
     [NotNull] IRelationalConnection relationalConnection,
     [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder)
     : base(
         transactionManager,
         databaseCreator,
         executionStrategyFactory,
         databaseProviders,
         commandLogger,
         concurrencyDetector)
 {
     RelationalConnection = relationalConnection;
     RawSqlCommandBuilder = rawSqlCommandBuilder;
 }
Exemple #30
0
 public SqlServerHistoryRepository(
     [NotNull] IDatabaseCreator databaseCreator,
     [NotNull] ISqlStatementExecutor executor,
     [NotNull] ISqlServerConnection connection,
     [NotNull] IDbContextOptions options,
     [NotNull] IMigrationsModelDiffer modelDiffer,
     [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
     [NotNull] IRelationalAnnotationProvider annotations,
     [NotNull] ISqlGenerator sqlGenerator)
     : base(
         databaseCreator,
         executor,
         connection,
         options,
         modelDiffer,
         migrationsSqlGenerator,
         annotations,
         sqlGenerator)
 {
 }
Exemple #31
0
        static void Main(string[] args)
        {
            IApplicationContext ctx = ContextRegistry.GetContext();

            IDatabaseCreator dc = ctx["IDatabaseCreator"] as IDatabaseCreator;

            dc.CreateDatabase(false);

//            IBlobDao blobDao = DatabaseContext.CreateDao<IBlobDao>();
//            IContainerDao containerDao = DatabaseContext.CreateDao<IContainerDao>();

//            Container cont = new Container()
//            {
////                ContainerIdentity = Guid.NewGuid().ToString(),
//                LastModified = DateTime.Now.ToUniversalTime(),
//                Name = @"/Shell/Settings",
//                Version = "1.0.0.0"
//            };

//            cont = containerDao.SaveOrUpdate(cont);
        }
Exemple #32
0
 internal CosmosStore(ICosmonautClient cosmonautClient,
                      string databaseName,
                      string overriddenCollectionName,
                      IDatabaseCreator databaseCreator     = null,
                      ICollectionCreator collectionCreator = null)
 {
     DatabaseName    = databaseName;
     CosmonautClient = cosmonautClient ?? throw new ArgumentNullException(nameof(cosmonautClient));
     Settings        = new CosmosStoreSettings(databaseName, cosmonautClient.DocumentClient.ServiceEndpoint.ToString(), string.Empty, cosmonautClient.DocumentClient.ConnectionPolicy);
     if (Settings.InfiniteRetries)
     {
         CosmonautClient.DocumentClient.SetupInfiniteRetries();
     }
     if (string.IsNullOrEmpty(Settings.DatabaseName))
     {
         throw new ArgumentNullException(nameof(Settings.DatabaseName));
     }
     _collectionCreator = collectionCreator ?? new CosmosCollectionCreator(CosmonautClient);
     _databaseCreator   = databaseCreator ?? new CosmosDatabaseCreator(CosmonautClient);
     InitialiseCosmosStore(overriddenCollectionName);
 }
Exemple #33
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 MyCatMigrator(
            [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,
            [NotNull] IDbContextOptions options,
            [NotNull] MyCatSchemaGenerator schemaCreator)
            : base(migrationsAssembly, historyRepository, databaseCreator, migrationsSqlGenerator, rawSqlCommandBuilder, migrationCommandExecutor, connection, sqlGenerationHelper, logger, 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        = (MyCatHistoryRepository)historyRepository;
            _databaseCreator          = (MyCatDatabaseCreator)databaseCreator;
            _migrationsSqlGenerator   = migrationsSqlGenerator;
            _rawSqlCommandBuilder     = rawSqlCommandBuilder;
            _migrationCommandExecutor = migrationCommandExecutor;
            _connection          = (MyCatRelationalConnection)connection;
            _sqlGenerationHelper = sqlGenerationHelper;
            _logger         = logger;
            _activeProvider = providerServices.InvariantName;
            _options        = options;
            _schemaCreator  = schemaCreator;
        }
 public DatabaseInitializer(IDatabaseCreator databaseCreator)
 {
     this.databaseCreator = databaseCreator;
 }
 public ErrorLogExporter(IErrorLogRepository repository, IDatabaseCreator databaseCreator)
 {
     _repository = repository;
     _databaseCreator = databaseCreator;
     _cancel = false;
 }
Exemple #36
0
 public DbManagerForm(IDatabaseCreator databaseCreator)
 {
     _databaseCreator = databaseCreator;
     InitializeComponent();
 }