Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to retrieve project metadata. Ensure it's an SDK-style project

I have a solution that is made up of 4 projects as shown in the screenshot Screenshot of my solution layout

The DbContext is inside NewKyc.Data project. The startup project is NewKyc

The ConfigureServices method of the Startup.cs contains the following block

services.AddDbContext<AppDbContext>(
           dbContextOptions => dbContextOptions
              .UseMySql(Configuration["ConnectionStrings:MySQLConnection"], 
              new MySqlServerVersion(new Version(mysql_version[0], mysql_version[1], mysql_version[2])), b=>b.MigrationsAssembly("NewKyc")

To add migrations, I write the following

dotnet ef migrations add EntityRelationshipsReview --startup-project "../NewKyc.csproj" --context AppDbContext --verbose

and I get the following messages

MSBUILD : error MSB1009: Project file does not exist. Switch: /Users/mac/Documents/Projects/folder/subfolder/subsubfolder/NewKyc.csproj

And this

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.

Where am I getting it wrong?

It is a .NET Core 3.1 project upgraded to .NET 6

like image 883
Josh Avatar asked Nov 04 '25 10:11

Josh


1 Answers

Since you've upgraded from Net Core 3.1 to 6.0 it's possible your dotnet-ef CLI tool is out of date, you can update it globally, according to the docs, using the following command:

dotnet tool update -g dotnet-ef

Or locally:

dotnet tool update --local dotnet-ef

like image 74
Timo Avatar answered Nov 07 '25 06:11

Timo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!