I have an ASP.NET Core Web Application (.NET Framework) project targeting .NET Framework 4.6.2.
I have introduced Entity Framework into the web project and have set up and run
dotnet ef migrations add Initial
from the web project directory. The migration is created, all is good.
I want to refactor the code so that my entities and db context are in a class library instead. So I have created a separate Class Library (.NET Framework) project, also targeting .NET Framework 4.6.2.
Still from the web project directory I run
dotnet ef migrations add Initial --startup-project . --project ..\MigrationTest.Entities
where MigrationTest.Entities
is my class library.
This time I get:
C:\Projects\Experiments\MigrationTestNoIdentity\MigrationTest.Entities\obj\MigrationTest.Entities.csproj.EntityFrameworkCore.targets(4,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "GetEFProjectMetadata". [C:\Projects\Experiments\MigrationTestNoIdentity\MigrationTest.Entities\MigrationTest.Entities.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.
It isn't a .NET Core project, so I try creating a .NET Core project instead. Running the migrations command then gives:
C:\Program Files\dotnet\sdk\1.0.3\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.Common.targets(73,5): error : Project 'C:\Projects\Experiments\MigrationTestNoIdentity\MigrationTest.Entities.Core\MigrationTest.Entities.Core.csproj' targets '.NETCoreApp,Version=v1.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.2'. [C:\Projects\Experiments\MigrationTestNoIdentity\MigrationTest.Entities.Core\MigrationTest.Entities.Core.csproj] C:\Program Files\dotnet\sdk\1.0.3\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for 'C:\Projects\Experiments\MigrationTestNoIdentity\MigrationTest.Entities.Core\MigrationTest.Entities.Core.csproj'. This can indicate a missing project reference. [C:\Projects\Experiments\MigrationTestNoIdentity\MigrationTest.Web\MigrationTest.Web.csproj]
And of course, the Core project cannot be referenced by the .NET project.
Is what I am trying to do a supported scenario? Is there some problem with my command line usage? Something else?