public MigrationsAssembly( [NotNull] DbContext context, [NotNull] IDbContextOptions options, [NotNull] IMigrationsIdGenerator idGenerator) { Check.NotNull(context, nameof(context)); Check.NotNull(options, nameof(options)); Check.NotNull(idGenerator, nameof(idGenerator)); var contextType = context.GetType(); var assemblyName = RelationalOptionsExtension.Extract(options)?.MigrationsAssembly; var assembly = assemblyName == null ? contextType.GetTypeInfo().Assembly : Assembly.Load(new AssemblyName(assemblyName)); _idGenerator = idGenerator; _migrations = new LazyRef <IReadOnlyList <Migration> >( () => assembly.GetConstructibleTypes() .Where(t => typeof(Migration).IsAssignableFrom(t.AsType()) && t.GetCustomAttribute <DbContextAttribute>()?.ContextType == contextType) .Select(t => (Migration)Activator.CreateInstance(t.AsType())) .OrderBy(m => m.Id) .ToList()); _modelSnapshot = new LazyRef <ModelSnapshot>( () => ( from t in assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(ModelSnapshot)) && t.GetCustomAttribute <DbContextAttribute>()?.ContextType == contextType select(ModelSnapshot) Activator.CreateInstance(t.AsType())) .FirstOrDefault()); }
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; }
/// <summary> /// <para> /// Creates the service dependencies parameter object for a <see cref="MigrationsScaffolder" />. /// </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="currentDbContext"> The current DbContext. </param> /// <param name="model"> The model. </param> /// <param name="migrationsAssembly"> The migrations assembly. </param> /// <param name="migrationsModelDiffer"> The migrations model differ. </param> /// <param name="migrationsIdGenerator"> The migrations ID generator. </param> /// <param name="migrationCodeGenerator"> The migrations code generator. </param> /// <param name="historyRepository"> The history repository. </param> /// <param name="operationReporter"> The operation reporter. </param> /// <param name="databaseProvider"> The database provider. </param> /// <param name="snapshotModelProcessor"> The snapshot model processor. </param> public MigrationsScaffolderDependencies( [NotNull] ICurrentDbContext currentDbContext, [NotNull] IModel model, [NotNull] IMigrationsAssembly migrationsAssembly, [NotNull] IMigrationsModelDiffer migrationsModelDiffer, [NotNull] IMigrationsIdGenerator migrationsIdGenerator, [NotNull] IMigrationsCodeGenerator migrationCodeGenerator, [NotNull] IHistoryRepository historyRepository, [NotNull] IOperationReporter operationReporter, [NotNull] IDatabaseProvider databaseProvider, [NotNull] ISnapshotModelProcessor snapshotModelProcessor) { Check.NotNull(currentDbContext, nameof(currentDbContext)); Check.NotNull(model, nameof(model)); Check.NotNull(migrationsAssembly, nameof(migrationsAssembly)); Check.NotNull(migrationsModelDiffer, nameof(migrationsModelDiffer)); Check.NotNull(migrationsIdGenerator, nameof(migrationsIdGenerator)); Check.NotNull(migrationCodeGenerator, nameof(migrationCodeGenerator)); Check.NotNull(historyRepository, nameof(historyRepository)); Check.NotNull(operationReporter, nameof(operationReporter)); Check.NotNull(databaseProvider, nameof(databaseProvider)); Check.NotNull(snapshotModelProcessor, nameof(snapshotModelProcessor)); CurrentDbContext = currentDbContext; Model = model; MigrationsAssembly = migrationsAssembly; MigrationsModelDiffer = migrationsModelDiffer; MigrationsIdGenerator = migrationsIdGenerator; MigrationCodeGenerator = migrationCodeGenerator; HistoryRepository = historyRepository; OperationReporter = operationReporter; DatabaseProvider = databaseProvider; SnapshotModelProcessor = snapshotModelProcessor; }
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; }
public MigrationsAssembly( [NotNull] DbContext context, [NotNull] IDbContextOptions options, [NotNull] IMigrationsIdGenerator idGenerator) { Check.NotNull(context, nameof(context)); Check.NotNull(options, nameof(options)); Check.NotNull(idGenerator, nameof(idGenerator)); var contextType = context.GetType(); var assemblyName = RelationalOptionsExtension.Extract(options)?.MigrationsAssembly; var assembly = assemblyName == null ? contextType.GetTypeInfo().Assembly : Assembly.Load(new AssemblyName(assemblyName)); _idGenerator = idGenerator; _migrations = new LazyRef<IReadOnlyDictionary<string, TypeInfo>>( () => ( from t in assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(Migration)) && t.GetCustomAttribute<DbContextAttribute>()?.ContextType == contextType let id = t.GetCustomAttribute<MigrationAttribute>()?.Id orderby id select new { Key = id, Element = t }) .ToDictionary(i => i.Key, i => i.Element)); _modelSnapshot = new LazyRef<ModelSnapshot>( () => ( from t in assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(ModelSnapshot)) && t.GetCustomAttribute<DbContextAttribute>()?.ContextType == contextType select (ModelSnapshot)Activator.CreateInstance(t.AsType())) .FirstOrDefault()); }
public MigrationsAssembly( [NotNull] DbContext context, [NotNull] IDbContextOptions options, [NotNull] IMigrationsIdGenerator idGenerator) { Check.NotNull(context, nameof(context)); Check.NotNull(options, nameof(options)); Check.NotNull(idGenerator, nameof(idGenerator)); var contextType = context.GetType(); var assemblyName = RelationalOptionsExtension.Extract(options)?.MigrationsAssembly; var assembly = assemblyName == null ? contextType.GetTypeInfo().Assembly : Assembly.Load(new AssemblyName(assemblyName)); _idGenerator = idGenerator; _migrations = new LazyRef<IReadOnlyList<Migration>>( () => assembly.GetConstructibleTypes() .Where(t => typeof(Migration).IsAssignableFrom(t.AsType()) && t.GetCustomAttribute<DbContextAttribute>()?.ContextType == contextType) .Select(t => (Migration)Activator.CreateInstance(t.AsType())) .OrderBy(m => m.Id) .ToList()); _modelSnapshot = new LazyRef<ModelSnapshot>( () => ( from t in assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(ModelSnapshot)) && t.GetCustomAttribute<DbContextAttribute>()?.ContextType == contextType select (ModelSnapshot)Activator.CreateInstance(t.AsType())) .FirstOrDefault()); }
public MigrationFinder(IServiceProvider serviceProvider, ShellContext shellContext, ICurrentDbContext context, IDbContextOptions options, IMigrationsIdGenerator migrationsIdGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(context, options, migrationsIdGenerator, logger) { Guard.ArgumentNotNull(context, nameof(context)); _shellContext = shellContext; _serviceProvider = serviceProvider; var contextType = context.Context.GetType(); _migrations = new LazyRef <IReadOnlyDictionary <string, TypeInfo> >( () => { var dic = ( from t in _shellContext.Blueprint.Dependencies.Select(d => d.Type.GetTypeInfo()) where t.IsSubclassOf(typeof(Migration)) && t.GetCustomAttribute <MigrationAttribute>() != null && this.CanApply(t, contextType) let id = t.GetCustomAttribute <MigrationAttribute>()?.Id orderby id select new { Key = id, Element = t }) .ToDictionary(i => i.Key, i => i.Element); return(new ReadOnlyDictionary <string, TypeInfo>(dic)); }); }
public MigrationsScaffolder( [NotNull] ICurrentDbContext currentContext, [NotNull] IModel model, [NotNull] IMigrationsAssembly migrationsAssembly, [NotNull] IMigrationsModelDiffer modelDiffer, [NotNull] IMigrationsIdGenerator idGenerator, [NotNull] MigrationsCodeGenerator migrationCodeGenerator, [NotNull] IHistoryRepository historyRepository, [NotNull] ILogger <MigrationsScaffolder> logger, [NotNull] IDatabaseProvider databaseProvider) { Check.NotNull(currentContext, nameof(currentContext)); 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(logger, nameof(logger)); Check.NotNull(databaseProvider, nameof(databaseProvider)); _contextType = currentContext.Context.GetType(); _model = model; _migrationsAssembly = migrationsAssembly; _modelDiffer = modelDiffer; _idGenerator = idGenerator; _migrationCodeGenerator = migrationCodeGenerator; _historyRepository = historyRepository; _logger = logger; _activeProvider = databaseProvider.InvariantName; }
public MigrationsAssembly( [NotNull] DbContext context, [NotNull] IDbContextOptions options, [NotNull] IMigrationsIdGenerator idGenerator) { Check.NotNull(context, nameof(context)); Check.NotNull(options, nameof(options)); Check.NotNull(idGenerator, nameof(idGenerator)); var contextType = context.GetType(); var assemblyName = RelationalOptionsExtension.Extract(options)?.MigrationsAssembly; Assembly = assemblyName == null ? contextType.GetTypeInfo().Assembly : Assembly.Load(new AssemblyName(assemblyName)); _idGenerator = idGenerator; _migrations = new LazyRef <IReadOnlyDictionary <string, TypeInfo> >( () => ( from t in Assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(Migration)) && t.GetCustomAttribute <DbContextAttribute>()?.ContextType == contextType let id = t.GetCustomAttribute <MigrationAttribute>()?.Id orderby id select new { Key = id, Element = t }) .ToDictionary(i => i.Key, i => i.Element)); _modelSnapshot = new LazyRef <ModelSnapshot>( () => ( from t in Assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(ModelSnapshot)) && t.GetCustomAttribute <DbContextAttribute>()?.ContextType == contextType select(ModelSnapshot) Activator.CreateInstance(t.AsType())) .FirstOrDefault()); }
public ColumnOrderMigrationAssembly(ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _context = currentContext.Context; }
public MigrationScaffolder( [NotNull] DbContext context, [NotNull] IModel model, [NotNull] IMigrationsAssembly migrationsAssembly, [NotNull] IMigrationsModelDiffer modelDiffer, [NotNull] IMigrationsIdGenerator idGenerator, [NotNull] MigrationCodeGenerator migrationCodeGenerator, [NotNull] IHistoryRepository historyRepository, [NotNull] ILoggerFactory loggerFactory) { 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)); _contextType = context.GetType(); _model = model; _migrationsAssembly = migrationsAssembly; _modelDiffer = modelDiffer; _idGenerator = idGenerator; _migrationCodeGenerator = migrationCodeGenerator; _historyRepository = historyRepository; _logger = new LazyRef <ILogger>(loggerFactory.CreateLogger <MigrationScaffolder>); }
public CacheMigrationAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _cacheDbContext = currentContext.Context as CacheDbContext; _cacheOptions = _cacheDbContext.CacheOptions; }
/// <summary> /// Initializes a new instance of the <see cref="EntityMigrationsAssembly"/> class. /// </summary> /// <param name="currentContext"></param> /// <param name="options"></param> /// <param name="idGenerator"></param> /// <param name="logger"></param> public EntityMigrationsAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _dbContext = ( EntityDbContext )currentContext.Context; }
public ForceSchemaMigrationsAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _currentContext = currentContext; }
public MigrationsAssembly(ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _contextType = currentContext.Context.GetType(); _autoPocoAssemblies = AppDomain.CurrentDomain.GetAssemblies() .Where(x => x.FullName.ToUpperInvariant().Contains("AUTOPOCOIO")) .ToArray(); }
/// <inheritdoc /> public SeedAwareMigrationsAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _env = currentContext.Context.GetService <IHostingEnvironment>(); _seedFactory = currentContext.Context.GetService <IMigrationSeedFactory>(); }
/// <inheritdoc /> public SeedAwareMigrationsAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _seedSpecs = currentContext.Context.GetService <IMigrationSeedsApplicabilitySpecification>(); _seedFactory = currentContext.Context.GetService <IMigrationSeedFactory>(); }
/// <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 MigrationsAssembly( [NotNull] ICurrentDbContext currentContext, [NotNull] IDbContextOptions options, [NotNull] IMigrationsIdGenerator idGenerator, [NotNull] IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) { Check.NotNull(currentContext, nameof(currentContext)); Check.NotNull(options, nameof(options)); Check.NotNull(idGenerator, nameof(idGenerator)); Check.NotNull(logger, nameof(logger)); var contextType = currentContext.Context.GetType(); var assemblyName = RelationalOptionsExtension.Extract(options)?.MigrationsAssembly; Assembly = assemblyName == null ? contextType.GetTypeInfo().Assembly : Assembly.Load(new AssemblyName(assemblyName)); _idGenerator = idGenerator; _migrations = new LazyRef <IReadOnlyDictionary <string, TypeInfo> >( () => { var result = new SortedList <string, TypeInfo>(); var items = from t in Assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(Migration)) && t.GetCustomAttribute <DbContextAttribute>()?.ContextType == contextType let id = t.GetCustomAttribute <MigrationAttribute>()?.Id orderby id select(id, t); foreach (var(id, t) in items) { if (id == null) { logger.MigrationAttributeMissingWarning(t); continue; } result.Add(id, t); } return(result); }); _modelSnapshot = new LazyRef <ModelSnapshot>( () => ( from t in Assembly.GetConstructibleTypes() where t.IsSubclassOf(typeof(ModelSnapshot)) && t.GetCustomAttribute <DbContextAttribute>()?.ContextType == contextType select(ModelSnapshot) Activator.CreateInstance(t.AsType())) .FirstOrDefault()); }
/// <summary> /// Clones this dependency parameter object with one service replaced. /// </summary> /// <param name="migrationsIdGenerator"> A replacement for the current dependency of this type. </param> /// <returns> A new parameter object with the given service replaced. </returns> public MigrationsScaffolderDependencies With([NotNull] IMigrationsIdGenerator migrationsIdGenerator) => new MigrationsScaffolderDependencies( CurrentDbContext, Model, MigrationsAssembly, MigrationsModelDiffer, migrationsIdGenerator, MigrationCodeGenerator, HistoryRepository, OperationReporter, DatabaseProvider, SnapshotModelProcessor);
public MultiDatabaseMigrationsAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { var multiDatabaseContext = currentContext.Context as IMultiDatabase; if (multiDatabaseContext != null) { _database = multiDatabaseContext.ActiveDatabase; } }
public MultiDatabaseMigrationsAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) #pragma warning disable EF1001 // Internal EF Core API usage. : base(currentContext, options, idGenerator, logger) #pragma warning restore EF1001 // Internal EF Core API usage. { var multiDatabaseContext = currentContext.Context as IMultiDatabase; if (multiDatabaseContext != null) { _database = multiDatabaseContext.ActiveDatabase; } }
/// <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 MigrationsAssembly( ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) { _contextType = currentContext.Context.GetType(); var assemblyName = RelationalOptionsExtension.Extract(options)?.MigrationsAssembly; Assembly = assemblyName == null ? _contextType.Assembly : Assembly.Load(new AssemblyName(assemblyName)); _idGenerator = idGenerator; _logger = logger; }
/// <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 MigrationsAssembly( [NotNull] ICurrentDbContext currentContext, [NotNull] IDbContextOptions options, [NotNull] IMigrationsIdGenerator idGenerator, [NotNull] IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) { Check.NotNull(currentContext, nameof(currentContext)); Check.NotNull(options, nameof(options)); Check.NotNull(idGenerator, nameof(idGenerator)); Check.NotNull(logger, nameof(logger)); _contextType = currentContext.Context.GetType(); var assemblyName = RelationalOptionsExtension.Extract(options)?.MigrationsAssembly; Assembly = assemblyName == null ? _contextType.GetTypeInfo().Assembly : Assembly.Load(new AssemblyName(assemblyName)); _idGenerator = idGenerator; _logger = logger; }
public SchemaAwareMigrationAssembly(ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger, IServiceProvider provider) : base(currentContext, options, idGenerator, logger) { _context = currentContext.Context; _serviceProvider = provider; }
public GirvsMigrationByTenantAssembly(ICurrentDbContext currentContext, IDbContextOptions options, IMigrationsIdGenerator idGenerator, IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { }
/// <inheritdoc /> public DbSchemaAwareMigrationAssembly([NotNull] ICurrentDbContext currentContext, [NotNull] IDbContextOptions options, [NotNull] IMigrationsIdGenerator idGenerator, [NotNull] IDiagnosticsLogger <DbLoggerCategory.Migrations> logger) : base(currentContext, options, idGenerator, logger) { _context = currentContext.Context; }