-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unrecognized command or argument 'optimize' on Entity Framework Core .NET Command-line Tools 5.0.7 #25135
Comments
Same here. |
Update EF Core Tools to the preview version?
|
Yes, mine is similar to @thangchung: Microsoft.EntityFrameworkCore.Design: 6.0.0-preview.5.21301.9 |
Thanks, @chrarnoldus. I could handle installing the newest tool and run For those people who have got the issue just like me, I write down what I did as below
$ dotnet tool update --global dotnet-ef --version 6.0.0-preview.5.21301.9
Tool 'dotnet-ef' was successfully updated from version '5.0.7' to version '6.0.0-preview.5.21301.9'.
$ # stand at the root project which has the DbContext reside
$ dotnet ef dbcontext optimize -c MainDbContext -o CompiledModels -n ProductService.Infrastructure
Build started...
Build succeeded.
Connection String: Server=localhost;Port=5432;Database=postgres;User Id=postgres;Password=P@ssw0rd;
Server=localhost;Port=5432;Database=postgres;User Id=postgres;Password=P@ssw0rd;
Successfully generated a compiled model, to use it call 'options.UseModel(ProductService.Infrastructure.MainDbContextModel.Instance)'. Run this command again when the model is modified.
services.AddDbContext<MainDbContext>(options =>
{
options.UseNpgsql(connString, sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(MainDbContext).Assembly.GetName().Name);
sqlOptions.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null);
}).UseSnakeCaseNamingConvention();
options.UseModel(ProductService.Infrastructure.MainDbContextModel.Instance); // this line of code is important
}); |
Hello, |
I had this problem, I set right project for Default Project in Package Manager Console so it Build succeeded |
I have found the blog post about EF on .NET Core 6 Preview 5 at https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-6-0-preview-5-compiled-models/
Then, I tried it on my laptop. I upgraded my EF Core CLI to the latest version as the guidance at https://docs.microsoft.com/en-gb/ef/core/cli/dotnet. But when I tried to run
dotnet ef dbcontext optimize -c MyContext -o MyFolder -n My.Namespace
. It threw the exception belowI wonder it might be has a nightly build for the EF tool for EF 6 preview 5, but not sure so that I posted the issue here.
My dev environment:
The text was updated successfully, but these errors were encountered: