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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.