Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. (Migrations)

I have a project with this structure enter image description here

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?

like image 981
Eugene Sukh Avatar asked Feb 27 '19 18:02

Eugene Sukh


1 Answers

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
like image 107
CodingYourLife Avatar answered Sep 29 '22 09:09

CodingYourLife