Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I've been researching a lot online but did not find a proper solution. I was trying to use Entity Framework Core with MySQL by using database-first scaffold method to mapping table model while always received this error when applied the command

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. 

This is the command I am using to scaffold the database model:

Scaffold-DbContext "server=localhost;port=3306;user=root;password=1234;database=world" "Pomelo.EntityFrameworkCore.MySql" -OutputDir .\Models -f 

And this is my .Net Core project setting:

  <ItemGroup>     <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />   </ItemGroup>    <ItemGroup>     <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />   </ItemGroup> 
like image 399
Kev D. Avatar asked Jun 04 '18 02:06

Kev D.


2 Answers

For EF Core 3

I think the powershell command has gone away for EF Core 3 so I'm using dotnet ef dbcontext scaffold

With this command, if you're converting a Scaffold-DbContext script the project name (parameter --project) needs to have .csproj on the end - it can't just the extensionless name.

like image 61
Simon_Weaver Avatar answered Sep 27 '22 19:09

Simon_Weaver


I got this error trying to add a new migration on the command line with dotnet ef migrations add NewMigration.

The solution for me was indeed to append --msbuildprojectextentionspath obj/local.

like image 43
Papa Mufflon Avatar answered Sep 27 '22 19:09

Papa Mufflon