When I run command for migration addition:
dotnet ef migrations add some_migration
it does not work and I get error:
CommandParseException: Unexpected option 'applicationName'.
at CommandTreeParserResult Parse(IEnumerable args) in CommandTreeParser.cs:69
at async Task Execute(IConfiguration configuration, IEnumerable args) in CommandExecutor.cs:49
at async Task RunAsync(IEnumerable args) in CommandApp.cs:81
at int Run(IEnumerable args) in CommandApp.cs:55
at int
$(string[] args) in Program.cs:44
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: The entry point exited without ever building an IHost.
Unable to create an object of type 'BloggingContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
It seems the application took control of all command line arguments so all other CLI tools do not work.
I made it working making some modifications in Program.cs:
// UNCOMMENT FOR to manipulate migrations (dotnet ef migrations ...)
var app = builder.Build();
app.Run();
// COMMENT OUT FOR to manipulate migrations (dotnet ef migrations ...)
// var registrar = new TypeRegistrar(builder);
// var app = new CommandApp(registrar);
// app.Configure(config =>
// {
// config.PropagateExceptions();
// // Register available commands
// config.AddCommand<InitCommand>("init")
// .WithDescription("Creates DB and seeds data");
// config.AddCommand<GetPostsCommand>("get-posts")
// .WithDescription("Queries the DB for posts");
// config.AddCommand<GetBlogsCommand>("get-blogs")
// .WithDescription("Queries the DB for blogs");
// });
// try
// {
// return app.Run(args);
// }
// catch (Exception ex)
// {
// AnsiConsole.WriteException(ex, ExceptionFormats.ShortenEverything);
// return -99;
// }
When I run command for migration addition:
dotnet ef migrations add some_migrationit does not work and I get error:
It seems the application took control of all command line arguments so all other CLI tools do not work.
I made it working making some modifications in Program.cs: