Beispiel #1
0
 public SqlChangeTrackingMigrationsModelDiffer(IRelationalTypeMappingSource typeMappingSource,
                                               IMigrationsAnnotationProvider migrationsAnnotations, IChangeDetector changeDetector,
                                               IUpdateAdapterFactory updateAdapterFactory,
                                               CommandBatchPreparerDependencies commandBatchPreparerDependencies) : base(typeMappingSource,
                                                                                                                         migrationsAnnotations, changeDetector, updateAdapterFactory, commandBatchPreparerDependencies)
 {
 }
        /// <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 virtual bool EnsureCreated(
            IUpdateAdapterFactory updateAdapterFactory,
            IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
        {
            lock (_lock)
            {
                var valuesSeeded = _tables == null;
                if (valuesSeeded)
                {
                    // ReSharper disable once AssignmentIsFullyDiscarded
                    _tables = CreateTables();

                    var updateAdapter = updateAdapterFactory.CreateStandalone();
                    var entries       = new List <IUpdateEntry>();
                    foreach (var entityType in updateAdapter.Model.GetEntityTypes())
                    {
                        foreach (var targetSeed in entityType.GetSeedData())
                        {
                            var entry = updateAdapter.CreateEntry(targetSeed, entityType);
                            entry.EntityState = EntityState.Added;
                            entries.Add(entry);
                        }
                    }

                    ExecuteTransaction(entries, updateLogger);
                }

                return(valuesSeeded);
            }
        }
        public DatabaseDependencies(
            [NotNull] IQueryCompilationContextFactory queryCompilationContextFactory,
            [NotNull] IUpdateAdapterFactory updateAdapterFactory)
        {
            Check.NotNull(queryCompilationContextFactory, nameof(queryCompilationContextFactory));
            Check.NotNull(updateAdapterFactory, nameof(updateAdapterFactory));

            QueryCompilationContextFactory = queryCompilationContextFactory;
            UpdateAdapterFactory           = updateAdapterFactory;
        }
 /// <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 CosmosDatabaseCreator(
     [NotNull] ICosmosClientWrapper cosmosClient,
     [NotNull] IModel model,
     [NotNull] IUpdateAdapterFactory updateAdapterFactory,
     [NotNull] IDatabase database)
 {
     _cosmosClient         = cosmosClient;
     _model                = model;
     _updateAdapterFactory = updateAdapterFactory;
     _database             = database;
 }
 /// <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 CosmosDatabaseCreator(
     CosmosClientWrapper cosmosClient,
     IModel model,
     IUpdateAdapterFactory updateAdapterFactory,
     IDatabase database)
 {
     _cosmosClient         = cosmosClient;
     _model                = model;
     _updateAdapterFactory = updateAdapterFactory;
     _database             = database;
 }
 public ShardingMigration(
     IRelationalTypeMappingSource typeMappingSource,
     IMigrationsAnnotationProvider migrationsAnnotations,
     IChangeDetector changeDetector,
     IUpdateAdapterFactory updateAdapterFactory,
     CommandBatchPreparerDependencies commandBatchPreparerDependencies
     )
     : base(typeMappingSource, migrationsAnnotations, changeDetector, updateAdapterFactory, commandBatchPreparerDependencies)
 {
     _existsShardingTables = Cache.ServiceProvider.GetService <ShardingContainer>().ExistsShardingTables;
 }
Beispiel #7
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 CosmosDatabaseCreator(
     ICosmosClientWrapper cosmosClient,
     ICurrentDbContext context,
     IUpdateAdapterFactory updateAdapterFactory,
     IDatabase database)
 {
     _cosmosClient         = cosmosClient;
     _designModel          = context.Context.DesignTimeModel;
     _updateAdapterFactory = updateAdapterFactory;
     _database             = database;
 }
 /// <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 CosmosDatabaseCreator(
     ICosmosClientWrapper cosmosClient,
     IDesignTimeModel designTimeModel,
     IUpdateAdapterFactory updateAdapterFactory,
     IDatabase database)
 {
     _cosmosClient         = cosmosClient;
     _designTimeModel      = designTimeModel;
     _updateAdapterFactory = updateAdapterFactory;
     _database             = database;
 }
 public MySQLMigrationsModelDiffer(
     [NotNull] IRelationalTypeMappingSource typeMappingSource,
     [NotNull] IMigrationsAnnotationProvider migrationsAnnotations,
     [NotNull] IChangeDetector changeDetector,
     [NotNull] IUpdateAdapterFactory updateAdapterFactory,
     [NotNull] CommandBatchPreparerDependencies commandBatchPreparerDependencies)
     : base(
         typeMappingSource,
         migrationsAnnotations,
         changeDetector,
         updateAdapterFactory,
         commandBatchPreparerDependencies)
 {
 }
Beispiel #10
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 InMemoryDatabase(
     DatabaseDependencies dependencies,
     IInMemoryStoreCache storeCache,
     IDbContextOptions options,
     IDesignTimeModel designTimeModel,
     IUpdateAdapterFactory updateAdapterFactory,
     IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
     : base(dependencies)
 {
     _store                = storeCache.GetStore(options);
     _designTimeModel      = designTimeModel;
     _updateAdapterFactory = updateAdapterFactory;
     _updateLogger         = updateLogger;
 }
Beispiel #11
0
        public virtual bool EnsureCreated(
            IUpdateAdapterFactory updateAdapterFactory,
            IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
        {
            lock (_lock)
            {
                var valuesSeeded = _tables == null;
                if (valuesSeeded)
                {
                    // ReSharper disable once AssignmentIsFullyDiscarded
                    _tables = CreateTables();

                    var updateAdapter = updateAdapterFactory.CreateStandalone();
                    var entries       = new List <IUpdateEntry>();
                    foreach (var entityType in updateAdapter.Model.GetEntityTypes())
                    {
                        var key = _useNameMatching ? (object)entityType.Name : entityType;
                        //Load Data
                        var table = EnsureTable(key, entityType);

                        foreach (var targetSeed in entityType.GetSeedData())
                        {
                            var entry = updateAdapter.CreateEntry(targetSeed, entityType);
                            entry.EntityState = EntityState.Added;

                            ////update
                            if (table.Exists(entry))
                            {
                                entry.EntityState = EntityState.Modified;
                                foreach (var property in entry.EntityType.GetProperties().ToList())
                                {
                                    if (!property.IsKey())
                                    {
                                        entry.SetPropertyModified(property);
                                    }
                                }
                            }

                            entries.Add(entry);
                        }
                    }

                    ExecuteTransaction(entries, updateLogger);
                }

                return(valuesSeeded);
            }
        }
Beispiel #12
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 InMemoryDatabase(
            [NotNull] DatabaseDependencies dependencies,
            [NotNull] IInMemoryStoreCache storeCache,
            [NotNull] IDbContextOptions options,
            [NotNull] IUpdateAdapterFactory updateAdapterFactory,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
            : base(dependencies)
        {
            Check.NotNull(storeCache, nameof(storeCache));
            Check.NotNull(options, nameof(options));
            Check.NotNull(updateAdapterFactory, nameof(updateAdapterFactory));
            Check.NotNull(updateLogger, nameof(updateLogger));

            _store = storeCache.GetStore(options);
            _updateAdapterFactory = updateAdapterFactory;
            _updateLogger         = updateLogger;
        }
Beispiel #13
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 InMemoryDatabase(
            DatabaseDependencies dependencies,
            IInMemoryStoreCache storeCache,
            IDbContextOptions options,
            ICurrentDbContext context,
            IUpdateAdapterFactory updateAdapterFactory,
            IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
            : base(dependencies)
        {
            Check.NotNull(storeCache, nameof(storeCache));
            Check.NotNull(options, nameof(options));
            Check.NotNull(updateAdapterFactory, nameof(updateAdapterFactory));
            Check.NotNull(updateLogger, nameof(updateLogger));

            _store                = storeCache.GetStore(options);
            _getDesignModel       = () => context.Context.DesignTimeModel;
            _updateAdapterFactory = updateAdapterFactory;
            _updateLogger         = updateLogger;
        }
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="updateAdapterFactory">
 ///     A replacement for the current dependency of this type.
 /// </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public DatabaseDependencies With([NotNull] IUpdateAdapterFactory updateAdapterFactory)
 => new DatabaseDependencies(QueryCompilationContextFactory, updateAdapterFactory);
Beispiel #15
0
 public CassandraMigrationsModelDiffer(RelationalConnectionDependencies relationalConnectionDependencies, IRelationalTypeMappingSource typeMappingSource, IMigrationsAnnotationProvider migrationsAnnotations, IChangeDetector changeDetector, IUpdateAdapterFactory updateAdapterFactory, CommandBatchPreparerDependencies commandBatchPreparerDependencies) : base(typeMappingSource, migrationsAnnotations, changeDetector, updateAdapterFactory, commandBatchPreparerDependencies)
 {
     _cassandraOptionsExtension = CassandraOptionsExtension.Extract(relationalConnectionDependencies.ContextOptions);
 }