Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project X targets framework '.NETStandard'. The Entity Framework Package Manager Console Tools don't support this framework

I'm trying to create a EF 6.4 migration in my solution which has net472 projects and netstandard projects, and I'm getting the following error:

Project 'ESP.Console' targets framework '.NETStandard'. The Entity Framework Package Manager Console Tools don't support this framework.

However, the 'ESP.Console' app doesn't target .NETStandard, it's targetting net472:

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

I have ESP.Console console app set as my startup project, and I have the ESP.Data project as my default project in the Package Manager console.

This is the setup for ESP.Data.csproj:

  <PropertyGroup>
    <TargetFrameworks>netstandard2.1;net472</TargetFrameworks>
    <EmbeddedResourceUseDependentUponConvention>true</EmbeddedResourceUseDependentUponConvention>
  </PropertyGroup>

I need this to target both netstandard and net472 while I am in the process of converting other applications in the solution to run on .net core.

Why am I getting this error? Is there another command like dotnet ef I can use that will work with my EF 6.4 project?

We've used EF migrations on this solution hundreds of times, but since the last time I needed to run a migration we've done two major changes to the solution- converted all the csproj files to use the new format (with PackageReference, etc) and converted the core projects to target either .net standard 2.0 or 2.1 where needed. So I think the issue is related to that.

Attempting to change ESP.Console application to run as netcoreapp3.1 gave the same error.

like image 640
DLeh Avatar asked Nov 06 '22 06:11

DLeh


1 Answers

I have found a solution to my problem, though it is a bit messy since I will need to make a temporary change to a csproj file in order to get this to run.

In my case, the ESP.Data (the project housing my DbContext) was targeting both net472 and netstandard2.1, I altered the Data project to remove the netstandard2.1 target framework. It seems there is a bug in VS that is saying that the StartupProject targets NetStandard instead of saying that the Target project does. After I create the migration, I can add the target back again.

I will be moving to .net core compilation soon, and will therefore need that netstandard 2.1 target at some point, so I'm not sure what I'll do when that comes. I may need to preserve a net472 console application to use in the future and continue targeting net472 in my data project after that migration is done in order to continue to create migrations.

like image 116
DLeh Avatar answered Nov 15 '22 06:11

DLeh