Wapac
Wapac

Reputation: 4178

dotnet ef run with --configuration causes MSB4006

I have .NET Core application. I am trying to execute

dotnet ef --configuration Release database update

to generate SQLite Entity Framework database (both restore and publish commands work flawlessly). This fails with

Project.csproj.EntityFrameworkCore.targets(4,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "GetEFProjectMetadata". [C:\Project\src\Project\Project.csproj] 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.

for which I was unable to google anything.

It does not occur if I execute

dotnet ef database update

which confuses me because the project's debug/release configuration are default.

What confuses me even more is that this command

dotnet ef --configuration Debug database update

does not work either, so this is ultimately related to the use of --configuration. Note that I use --configuration Release with publish command and there is no problem with it.

I have tested this on Windows 10 system with MSVS2017 installed, as well on a clean Windows 7 system where I installed the latest 64-bit .NET Core SDK. Both systems behave exactly the same.

The project file does not define any BaseIntermediateOutputPath or MSBuildProjectExtensionsPath.

The project dependencies on EF in project file are as follows:

<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0" />

and

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />

The error is present even if I remove most of the stuff from the project file.

Upvotes: 1

Views: 4521

Answers (1)

Nick Spiers
Nick Spiers

Reputation: 2354

It looks like this will be fixed in 2.0, but the current workaround is to also specify

--framework

https://github.com/aspnet/EntityFramework/issues/8399

In my instance it was

--framework netcoreapp1.1

Upvotes: 3

Related Questions