public virtual MigrationFiles Save( [NotNull] string projectDir, [NotNull] ScaffoldedMigration migration, [CanBeNull] string outputDir) { Check.NotEmpty(projectDir, nameof(projectDir)); Check.NotNull(migration, nameof(migration)); var lastMigrationFileName = migration.PreviousMigrationId + migration.FileExtension; var migrationDirectory = outputDir ?? GetDirectory(projectDir, lastMigrationFileName, migration.MigrationSubNamespace); var migrationFile = Path.Combine(migrationDirectory, migration.MigrationId + migration.FileExtension); var migrationMetadataFile = Path.Combine(migrationDirectory, migration.MigrationId + ".Designer" + migration.FileExtension); var modelSnapshotFileName = migration.SnapshotName + migration.FileExtension; var modelSnapshotDirectory = outputDir ?? GetDirectory(projectDir, modelSnapshotFileName, migration.SnapshotSubnamespace); var modelSnapshotFile = Path.Combine(modelSnapshotDirectory, modelSnapshotFileName); _logger.Value.LogDebug(DesignCoreStrings.WritingMigration(migrationFile)); Directory.CreateDirectory(migrationDirectory); File.WriteAllText(migrationFile, migration.MigrationCode, Encoding.UTF8); File.WriteAllText(migrationMetadataFile, migration.MetadataCode, Encoding.UTF8); _logger.Value.LogDebug(DesignCoreStrings.WritingSnapshot(modelSnapshotFile)); Directory.CreateDirectory(modelSnapshotDirectory); File.WriteAllText(modelSnapshotFile, migration.SnapshotCode, Encoding.UTF8); return(new MigrationFiles { MigrationFile = migrationFile, MetadataFile = migrationMetadataFile, SnapshotFile = modelSnapshotFile }); }