9

I used the dotnet CLI command dotnet new classlib -o ProjectName to create a class library and added the EF Core Package using dotnet add package but when I tried to run some dotnet ef commands it threw the following error.

Error Message

Later, I realized that dotnet new classlib creates classlib (.netstandard) instead of creating classlib (core). I would like to know is there anyway to create classlib (core) using dotnet CLI or any alternate for classlib (core).

MrTesla
  • 99
  • 2
  • 9

1 Answers1

18

You can always use -h to check the class lib. So, when you run dotnet new classlib -h, you would find an option -f to set the framework. Basically, you can run the following if you would like to create a new .net core project:

dotnet new classlib -f netcoreapp2.2

However, since version 2.2 is just a couple of days old, you might either want to install it or use dotnet new classlib -f netcoreapp2.1.

You can also convert your existing netstandard app to .net core by updating the .csproj file.

Neville Nazerane
  • 6,622
  • 3
  • 46
  • 79
  • 2
    It's strange that this question/answer isn't more popular. I was trying to use DataAnnotations that permit a POCO to declare validation rules. – Peter L Aug 09 '19 at 00:24