public virtual MigrationFiles AddMigration(
            [NotNull] string name,
            [CanBeNull] string contextType)
        {
            Check.NotEmpty(name, nameof(name));

            using (var context = _contextOperations.CreateContext(contextType))
            {
                var services = _servicesBuilder.Build(context);
                EnsureServices(services);

                var scaffolder = services.GetRequiredService <MigrationsScaffolder>();
                var migration  = scaffolder.ScaffoldMigration(name, _rootNamespace);
                var files      = scaffolder.Save(_projectDir, migration);

                return(files);
            }
        }
Beispiel #2
0
        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);
            }
        }