Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not create classlib (core) using dotnet CLI

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).

like image 905
MrTesla Avatar asked Dec 06 '18 05:12

MrTesla


People also ask

Which command in dotnet CLI is used to build a .NET core application?

dotnet new <TEMPLATE> - .NET CLI The dotnet new command creates new . NET projects based on the specified template.


1 Answers

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.

like image 100
Neville Nazerane Avatar answered Sep 27 '22 21:09

Neville Nazerane