Can't Scaffold Entity Framework: MSB4006: There is a circular dependency in the target dependency graph involving target "GetEFProjectMetadata".
Describe the bug When I try to issue the dotnet ef dbcontext scaffold command, I get this error:
error MSB4006: There is a circular dependency in the target dependency graph involving target "GetEFProjectMetadata". [ ..path..\TestTemplateEF.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.
To Reproduce Steps to reproduce the behavior: Create an MVVM Light project with SQL data and just the main page -- no other options go to the Package Manager Console and issue these commands:
cd {the .core directory}
dotnet ef dbcontext scaffold "Server={server name};Initial Catalog={dbname};Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models --startup-project={pathToMainProject}\TestTemplateEF20191108B -Verbose
System VS Version: 2019 WinTS Version: 3.5.19310.1 -- fresh install Windows Build: 18362.418
I added a repo here: https://github.com/MissyGH/EFMVVMWTSBugReport
HI @MissyGH, you should add a dummy .NET Core console app to your solution to be able to use the Entity Framework CLI Tools with your UWP Project as suggested in https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet#other-target-frameworks
The CLI tools work with .NET Core projects and .NET Framework projects. Apps that have the EF Core model in a .NET Standard class library might not have a .NET Core or .NET Framework project. For example, this is true of Xamarin and Universal Windows Platform apps. In such cases, you can create a .NET Core console app project whose only purpose is to act as startup project for the tools. The project can be a dummy project with no real code — it is only needed to provide a target for the tooling. Why is a dummy project required? As mentioned earlier, the tools have to execute application code at design time. To do that, they need to use the .NET Core runtime. When the EF Core model is in a project that targets .NET Core or .NET Framework, the EF Core tools borrow the runtime from the project. They can't do that if the EF Core model is in a .NET Standard class library. The .NET Standard is not an actual .NET implementation; it's a specification of a set of APIs that .NET implementations must support. Therefore .NET Standard is not sufficient for the EF Core tools to execute application code. The dummy project you create to use as startup project provides a concrete target platform into which the tools can load the .NET Standard class library.
Thanks -- I'll try it. M.
@MissyGH, hope the docs helped. I'll close this issue, please reopen if you have further doubts related to Windows Template Studio.