I have a project with this structure
TooSeeWeb.Infrastructure is for migrations.
When I try to run migrations with this command
dotnet ef migrations add ExampleMigration -s ..\TooSeeWeb
I have this error
Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option
How I can fix this?
This is 2 years old but I was just in the same situation so it is still relevant. It's first result on Google for this error.
So I can see in your Screenshot that you are not in the standard Windows Visual Studio so I assume you are not on Windows (makes a difference in how to write file paths). Also I can see that you used ..\TooSeeWeb
with a backslash.
Solution: Change all \
to a /
forward slash so in your case I guess it would be:
dotnet ef migrations add ExampleMigration -s ../TooSeeWeb
For me it was working on Windows but failing on macOS (OS X) with this error:
Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
Additionally it gives the information (that gives a better hint):
MSBUILD : error MSB1009: Project file does not exist.
Here my more complex statement WORKING with forward slashes:
dotnet ef --startup-project ./MainProject.csproj migrations add MyMigration --context MyDbContextPostgreSQL --output-dir Migrations --project ../MyDatabasePostgreSQL/MyDatabasePostgreSQL.csproj
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With