I am trying to develop my projects to be cross platform. I have created several class libraries in this way:
But, when I was using Entity Framework to scaffold my DB, the nuget packages needed didn't install except when used in Console application.
Here is the difference, the console app references the .NET Core:
And the Class library references NET Standard:
So why they are both under .NET Core but referencing different libraries? Are both of them Cross Platform or only the console which is using .NET Core? And should I avoid using Class libraries in this case?
"So why they are both under .NET Core but referencing different libraries?"
The recommended NET version to create libraries for is now Net Standard Library. That is why the default when you create a class library is the net standard version instead of Net Core. You could manually change that but is not recommended see also this blog post about Introducing .NET Standard Library.
Are both of them Cross Platform or only the console which is using .NET Core?
Yes, they are both cross platform.
And should I avoid using Class libraries in this case?
No, by all means use Class Libraries every time is possible. This was not the original intent of Microsoft in the beginning but they change their mind later, so not all packages are yet compatible with .net standard that's is why you can not use a the net standard version to have a scaffold project because "Microsoft.EntityFrameworkCore.Tools" at the moment is only compatible with Net core, but it will probably be compatible with DotNet Standard soon
As I said if you really want to keep the scaffold option, then you can use a class library project and change manually in the project.json the .net version, then once is compatible you can switch back to .net standard. Your other projects such as a service or data layer depending how you want to keep the separation can be a class library with dotnet standard and they will be able to work correctly.
Or you could have a console application (.net core) appart from your original solution and copy and paste into your real class library using .net standard. (This is what we are currently doing in project)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With