public virtual MigrationFiles AddMigration( [NotNull] string name, [CanBeNull] string outputDir, [CanBeNull] string contextType) { Check.NotEmpty(name, nameof(name)); outputDir = string.IsNullOrWhiteSpace(outputDir) ? null : outputDir; var subNamespace = SubnamespaceFromOutputPath(outputDir); using (var context = _contextOperations.CreateContext(contextType)) { var services = _servicesBuilder.Build(context); EnsureServices(services); var scaffolder = services.GetRequiredService <MigrationsScaffolder>(); var migration = scaffolder.ScaffoldMigration(name, _rootNamespace, subNamespace); var files = scaffolder.Save(_projectDir, migration, outputDir); return(files); } }
public virtual MigrationFiles AddMigration( [NotNull] string name, [CanBeNull] string outputDir, [CanBeNull] string contextType) { Check.NotEmpty(name, nameof(name)); var subNamespace = outputDir != null ? string.Join(".", outputDir.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)) : null; using (var context = _contextOperations.CreateContext(contextType)) { var services = _servicesBuilder.Build(context); EnsureServices(services); var scaffolder = services.GetRequiredService <MigrationsScaffolder>(); var migration = scaffolder.ScaffoldMigration(name, _rootNamespace, subNamespace); var files = scaffolder.Save(_projectDir, migration); return(files); } }