public virtual IEnumerable<Migration> GetMigrations([CanBeNull] string contextTypeName) { var contextType = GetContextType(contextTypeName); using (var context = CreateContext(contextType)) { var services = new DesignTimeServices(((IAccessor<IServiceProvider>)context).Service); var migrationAssembly = services.GetRequiredService<MigrationAssembly>(); return migrationAssembly.Migrations; } }
public virtual IEnumerable <Migration> GetMigrations([CanBeNull] string contextTypeName) { var contextType = GetContextType(contextTypeName); using (var context = CreateContext(contextType)) { var services = new DesignTimeServices(((IAccessor <IServiceProvider>)context).Service); var migrationAssembly = services.GetRequiredService <MigrationAssembly>(); return(migrationAssembly.Migrations); } }
public virtual MigrationFiles RemoveMigration( [CanBeNull] string contextTypeName, [NotNull] string rootNamespace, [NotNull] string projectDir) { Check.NotEmpty(rootNamespace, nameof(rootNamespace)); Check.NotEmpty(projectDir, nameof(projectDir)); var contextType = GetContextType(contextTypeName); using (var context = CreateContext(contextType)) { var services = new DesignTimeServices(((IAccessor <IServiceProvider>)context).Service); var scaffolder = CreateScaffolder(services); return(scaffolder.RemoveMigration(projectDir, rootNamespace)); } }
public virtual MigrationFiles AddMigration( [NotNull] string migrationName, [CanBeNull] string contextTypeName, [NotNull] string rootNamespace, [NotNull] string projectDir) { Check.NotEmpty(migrationName, nameof(migrationName)); Check.NotEmpty(rootNamespace, nameof(rootNamespace)); Check.NotEmpty(projectDir, nameof(projectDir)); var contextType = GetContextType(contextTypeName); using (var context = CreateContext(contextType)) { var services = new DesignTimeServices(((IAccessor<IServiceProvider>)context).Service); var scaffolder = CreateScaffolder(services); var migration = scaffolder.ScaffoldMigration(migrationName, rootNamespace); var files = scaffolder.Write(projectDir, migration); return files; } }
public virtual MigrationFiles AddMigration( [NotNull] string migrationName, [CanBeNull] string contextTypeName, [CanBeNull] string startupAssemblyName, [NotNull] string rootNamespace, [NotNull] string projectDir) { Check.NotEmpty(migrationName, nameof(migrationName)); Check.NotEmpty(rootNamespace, nameof(rootNamespace)); Check.NotEmpty(projectDir, nameof(projectDir)); var contextType = GetContextType(contextTypeName); using (var context = CreateContext(contextType, startupAssemblyName)) { var services = new DesignTimeServices(((IAccessor <IServiceProvider>)context).Service); var scaffolder = CreateScaffolder(services); var migration = scaffolder.ScaffoldMigration(migrationName, rootNamespace); var files = scaffolder.Write(projectDir, migration); return(files); } }
public virtual MigrationFiles RemoveMigration( [CanBeNull] string contextTypeName, [CanBeNull] string startupAssemblyName, [NotNull] string rootNamespace, [NotNull] string projectDir) { Check.NotEmpty(rootNamespace, nameof(rootNamespace)); Check.NotEmpty(projectDir, nameof(projectDir)); var contextType = GetContextType(contextTypeName); using (var context = CreateContext(contextType, startupAssemblyName)) { var services = new DesignTimeServices(((IAccessor<IServiceProvider>)context).Service); var scaffolder = CreateScaffolder(services); var files = scaffolder.RemoveMigration(projectDir, rootNamespace); _logger.Value.LogInformation(Strings.Done); return files; } }