public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Updates the database to a specified migration"; var migration = command.Argument( "[migration]", "The target migration. If '0', all migrations will be reverted. If omitted, all pending migrations will be applied"); var context = command.Option( "-c|--context <context>", "The DbContext to use. If omitted, the default DbContext is used"); var startupProject = command.Option( "-s|--startup-project <project>", "The startup project to use. If omitted, the current project is used."); var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => Execute(commonOptions.Value(), migration.Value, context.Value(), startupProject.Value(), environment.Value())); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "List the migrations"; var context = command.Option( "-c|--context <context>", "The DbContext to use. If omitted, the default DbContext is used"); var startupProject = command.Option( "-s|--startup-project <project>", "The startup project to use. If omitted, the current project is used."); var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); var json = command.JsonOption(); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => Execute(commonOptions.Value(), context.Value(), startupProject.Value(), environment.Value(), json.HasValue() ? (Action <IEnumerable <MigrationInfo> >)ReportJsonResults : ReportResults)); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Remove the last migration"; var context = command.Option( "-c|--context <context>", "The DbContext to use. If omitted, the default DbContext is used"); var startupProject = command.Option( "-s|--startup-project <project>", "The startup project to use. If omitted, the current project is used."); var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); var force = command.Option( "-f|--force", "Removes the last migration without checking the database. If the last migration has been applied to the database, you will need to manually reverse the changes it made.", CommandOptionType.NoValue); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => Execute(commonOptions.Value(), context.Value(), startupProject.Value(), environment.Value(), force.HasValue())); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Drop the database for specific environment"; var startupProject = command.Option( "-s|--startup-project <project>", "The startup project to use. If omitted, the current project is used."); var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); var context = command.Option( "-c|--context <context>", "The DbContext to use. If omitted, the default DbContext is used"); var force = command.Option( "-f|--force", "Drop without confirmation"); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => Execute(commonOptions.Value(), context.Value(), startupProject.Value(), environment.Value(), force.HasValue())); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Commands to manage your database"; command.HelpOption(); command.VerboseOption(); command.Command("update", c => DatabaseUpdateCommand.Configure(c, commonOptions)); command.Command("drop", c => DatabaseDropCommand.Configure(c, commonOptions)); command.OnExecute(() => command.ShowHelp()); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Commands to manage your DbContext types"; command.HelpOption(); command.VerboseOption(); command.Command("list", c => DbContextListCommand.Configure(c, commonOptions)); command.Command("scaffold", c => DbContextScaffoldCommand.Configure(c, commonOptions)); command.OnExecute(() => command.ShowHelp()); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Commands to manage your migrations"; command.HelpOption(); command.VerboseOption(); command.Command("add", c => MigrationsAddCommand.Configure(c, commonOptions)); command.Command("list", c => MigrationsListCommand.Configure(c, commonOptions)); command.Command("remove", c => MigrationsRemoveCommand.Configure(c, commonOptions)); command.Command("script", c => MigrationsScriptCommand.Configure(c, commonOptions)); command.OnExecute(() => command.ShowHelp()); }
public static CommandLineApplication Create(ref string[] args) { EnsureValidDispatchRecipient(ref args); var app = new CommandLineApplication() { // Technically, the real "dotnet-ef.dll" is in Microsoft.EntityFrameworkCore.Tools, // but this name is what the help usage displays Name = "dotnet ef", FullName = "Entity Framework .NET Core CLI Commands" }; app.HelpOption(); app.VerboseOption(); app.VersionOption(GetVersion); var commonOptions = new CommonCommandOptions { // required Assembly = app.Option(AssemblyOptionTemplate + " <ASSEMBLY>", "The assembly file to load."), // optional StartupAssembly = app.Option(StartupAssemblyOptionTemplate + " <ASSEMBLY>", "The assembly file containing the startup class."), DataDirectory = app.Option(DataDirectoryOptionTemplate + " <DIR>", "The folder used as the data directory (defaults to current working directory)."), ProjectDirectory = app.Option(ProjectDirectoryOptionTemplate + " <DIR>", "The folder used as the project directory (defaults to current working directory)."), ContentRootPath = app.Option(ContentRootPathOptionTemplate + " <DIR>", "The folder used as the content root path for the application (defaults to application base directory)."), RootNamespace = app.Option(RootNamespaceOptionTemplate + " <NAMESPACE>", "The root namespace of the target project (defaults to the project assembly name).") }; app.Command("database", c => DatabaseCommand.Configure(c, commonOptions)); app.Command("dbcontext", c => DbContextCommand.Configure(c, commonOptions)); app.Command("migrations", c => MigrationsCommand.Configure(c, commonOptions)); app.OnExecute( () => { WriteLogo(); app.ShowHelp(); }); return(app); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Add a new migration"; var name = command.Argument("[name]", "The name of the migration"); var outputDir = command.Option( "-o|--output-dir <path>", "The directory (and sub-namespace) to use. If omitted, \"Migrations\" is used."); var context = command.Option( "-c|--context <context>", "The DbContext to use. If omitted, the default DbContext is used"); var startupProject = command.Option( "-s|--startup-project <project>", "The startup project to use. If omitted, the current project is used."); var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); var json = command.JsonOption(); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => { if (string.IsNullOrEmpty(name.Value)) { Reporter.Error.WriteLine(("Missing required argument '" + name.Name + "'").Bold().Red()); command.ShowHelp(); return(1); } return(Execute(commonOptions.Value(), name.Value, outputDir.Value(), context.Value(), startupProject.Value(), environment.Value(), json.HasValue() ? (Action <MigrationFiles>)ReportJson : null)); }); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "List your DbContext types"; var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); var json = command.JsonOption(); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => Execute(commonOptions.Value(), environment.Value(), json.HasValue() ? (Action <IEnumerable <Type> >)ReportJsonResults : ReportResults) ); }
public static CommandLineApplication Create() { var app = new CommandLineApplication() { Name = GetToolName(), FullName = "Entity Framework .NET Core CLI Commands" }; app.HelpOption(); app.VerboseOption(); app.VersionOption(GetVersion); var commonOptions = new CommonCommandOptions { Framework = app.Option(FrameworkOptionTemplate + " <FRAMEWORK>", "Target framework to load", CommandOptionType.SingleValue), Configuration = app.Option(ConfigOptionTemplate + " <CONFIGURATION>", "Configuration under which to load", CommandOptionType.SingleValue), BuildBasePath = app.Option(BuildBasePathOptionTemplate + " <OUTPUT_DIR>", "Directory in which to find temporary outputs", CommandOptionType.SingleValue), NoBuild = app.Option(NoBuildOptionTemplate, "Do not build before executing", CommandOptionType.NoValue) }; app.Command("database", c => DatabaseCommand.Configure(c, commonOptions)); app.Command("dbcontext", c => DbContextCommand.Configure(c, commonOptions)); app.Command("migrations", c => MigrationsCommand.Configure(c, commonOptions)); app.OnExecute( () => { WriteLogo(); app.ShowHelp(); }); return(app); }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Generate a SQL script from migrations"; var from = command.Argument( "[from]", "The starting migration. If omitted, '0' (the initial database) is used"); var to = command.Argument( "[to]", "The ending migration. If omitted, the last migration is used"); var output = command.Option( "-o|--output <file>", "The file to write the script to instead of stdout"); var idempotent = command.Option( "-i|--idempotent", "Generates an idempotent script that can used on a database at any migration"); var context = command.Option( "-c|--context <context>", "The DbContext to use. If omitted, the default DbContext is used"); var startupProject = command.Option( "-s|--startup-project <project>", "The startup project to use. If omitted, the current project is used."); var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => Execute(commonOptions.Value(), from.Value, to.Value, output.Value(), idempotent.HasValue(), context.Value(), startupProject.Value(), environment.Value())); }
public static CommandLineApplication Create() { var app = new CommandLineApplication() { // Technically, the real "dotnet-ef.dll" is in Microsoft.EntityFrameworkCore.Tools, // but this name is what the help usage displays Name = "dotnet ef", FullName = "Entity Framework .NET Core CLI Commands" }; app.HelpOption(); app.VerboseOption(); app.VersionOption(GetVersion); var commonOptions = new CommonCommandOptions { Framework = app.Option(FrameworkOptionTemplate + " <FRAMEWORK>", "Target framework to load", CommandOptionType.SingleValue), Configuration = app.Option(ConfigOptionTemplate + " <CONFIGURATION>", "Configuration under which to load", CommandOptionType.SingleValue) }; app.Command("database", c => DatabaseCommand.Configure(c, commonOptions)); app.Command("dbcontext", c => DbContextCommand.Configure(c, commonOptions)); app.Command("migrations", c => MigrationsCommand.Configure(c, commonOptions)); app.OnExecute( () => { WriteLogo(); app.ShowHelp(); }); return(app); }
public static CommandLineApplication Create(ref string[] args) { EnsureValidDispatchRecipient(ref args); var app = new CommandLineApplication() { // Technically, the real "dotnet-ef.dll" is in Microsoft.EntityFrameworkCore.Tools, // but this name is what the help usage displays Name = "dotnet ef", FullName = "Entity Framework .NET Core CLI Commands" }; app.HelpOption(); app.VerboseOption(); app.VersionOption(GetVersion); var commonOptions = new CommonCommandOptions { // required Assembly = app.Option(AssemblyOptionTemplate + " <ASSEMBLY>", "The assembly file to load."), // optional StartupAssembly = app.Option(StartupAssemblyOptionTemplate + " <ASSEMBLY>", "The assembly file containing the startup class."), DataDirectory = app.Option(DataDirectoryOptionTemplate + " <DIR>", "The folder used as the data directory (defaults to current working directory)."), ProjectDirectory = app.Option(ProjectDirectoryOptionTemplate + " <DIR>", "The folder used as the project directory (defaults to current working directory)."), ContentRootPath = app.Option(ContentRootPathOptionTemplate + " <DIR>", "The folder used as the content root path for the application (defaults to application base directory)."), RootNamespace = app.Option(RootNamespaceOptionTemplate + " <NAMESPACE>", "The root namespace of the target project (defaults to the project assembly name).") }; app.Command("database", c => DatabaseCommand.Configure(c, commonOptions)); app.Command("dbcontext", c => DbContextCommand.Configure(c, commonOptions)); app.Command("migrations", c => MigrationsCommand.Configure(c, commonOptions)); app.OnExecute( () => { WriteLogo(); app.ShowHelp(); }); return app; }
public static void Configure([NotNull] CommandLineApplication command, [NotNull] CommonCommandOptions commonOptions) { command.Description = "Scaffolds a DbContext and entity type classes for a specified database"; var connection = command.Argument( "[connection]", "The connection string of the database"); var provider = command.Argument( "[provider]", "The provider to use. For example, EntityFramework.MicrosoftSqlServer"); var dataAnnotations = command.Option( "-a|--data-annotations", "Use DataAnnotation attributes to configure the model where possible. If omitted, the output code will use only the fluent API.", CommandOptionType.NoValue); var context = command.Option( "-c|--context <name>", "Name of the generated DbContext class."); var force = command.Option( "-f|--force", "Force scaffolding to overwrite existing files. Otherwise, the code will only proceed if no output files would be overwritten.", CommandOptionType.NoValue); var outputDir = command.Option( "-o|--output-dir <path>", "Directory of the project where the classes should be output. If omitted, the top-level project directory is used."); var schemas = command.Option( "--schema <schema>", "Selects a schema for which to generate classes.", CommandOptionType.MultipleValue); var tables = command.Option( "-t|--table <schema.table>", "Selects a table for which to generate classes.", CommandOptionType.MultipleValue); var environment = command.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used."); command.HelpOption(); command.VerboseOption(); command.OnExecute( () => { if (string.IsNullOrEmpty(connection.Value)) { Reporter.Error.WriteLine(("Missing required argument '" + connection.Name + "'").Bold().Red()); command.ShowHelp(); return(Task.FromResult(1)); } if (string.IsNullOrEmpty(provider.Value)) { Reporter.Error.WriteLine(("Missing required argument '" + provider.Name + "'").Bold().Red()); command.ShowHelp(); return(Task.FromResult(1)); } return(ExecuteAsync(commonOptions.Value(), connection.Value, provider.Value, dataAnnotations.HasValue(), context.Value(), force.HasValue(), outputDir.Value(), schemas.Values, tables.Values, environment.Value())); }); }