I've been using
dotnet ef --startup-project "../WebApp/WebAppProject/" migrations add migrationName
To generate migrations, but after upgrading EF Core version from 2.1 to 3.1 it started throwing error like this:
An error occurred while accessing the Microsoft.Extensions.Hosting
services.
Continuing without the application service provider.
Error: Problem with determining the path to the folder storing the application files
System.MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder`1.HasIndex(System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,System.Object>>)'.
at
at base.OnModelCreating(builder);
of
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ApplyConfigurationsFromAssembly(typeof(Context).Assembly);
}
My projects / folder structure
Container
|
|
|----- Common (project) (here I'm executing above mentioned command as I used to do it)
|
|
|
|----- Persistence
|
|
| Context.cs
| ----- Migrations
|
| Migration1.cs
| Migration2.cs
| Migration3.cs
| ....cs
|
| ----- WebApp
| ----- WebAppProject (project)
| WebApp.csproj
| Startup.cs
| Program.cs
DesignTimeDbContextFactory
class is being located in Program.cs
inside WebApp/WebAppProject/
Generally path is fine, nothing has changed and it's been working, but after upgrading versions I'm not sure how to help that tool discover my db
dotnet tool list --global 3.1.7 dotnet-ef
The exact command works without issues with your solution structure, unless you have some old library versions referenced or are using some old EF Core CLI version.
Make sure, that all references to EF Core libraries are up-to-date (meaning 3.1.7) and that the EF Core Tools are installed with the same version as well.
(Feel free to post the content of your project files and a --verbose
output of the EF Core CLI command, if you think that this is already the case.)