The question I had was “What is exact the difference between .NET Core and .NET Standard (and when to use it)?” and “Why should we migrate?”. So, the best way to find that out, is to convert an existing project while reading all the documentation.
Difference .NET Standard and .NET Core
You can compare .NET Standard to an Interface and .NET Core to a Class. The main purpose of .NET Standard is to share your code between different runtimes like .NET Core, Xamarin, … It’s important that those runtimes implement this specification.
It’s also good to know that the higher version of .NET Standard contains more APIs but is less supported by platforms. So, my advice is to use the lowest version as possible to have more support. We can say that a .NET Core Class Library is built upon the .NET Standard. With .NET Core you can make an executable project, not with .NET Standard. For more info: .NET Standard versions.
In a real-world example, I used .NET Standard for a Domain Class Library. I noticed that I still can reference to existing .NET Framework class libraries. I used .NET Standard here to be future proof. When we may be going to write a Xamarin application, I can use and share this library. It will also be platform independent.
The corresponding (NUnit) test project is created using .NET Core because we need to execute the tests.
For the Base Library class which I’m going to use for the different projects and solutions I used again .NET Standard because I want to be able to use it for every project and platform.
I used an ASP .NET Core project for the REST API. Not much is changed but ApiController for example is now migrated, so you can’t use it anymore as a base class. You can still use it as an attribute (since .NET Core 2.1). I hope I can see the performance improvements in the future.
By using .NET Standard projects, I can reuse them for different views like Xamarin, WPF, …. Maybe at this moment your projects don’t need to support different platforms.
For the communication to the backend I created a .NET Standard library.
As a consultant and an early adopter, I always want to use and learn the latest versions. So, I will always choose for migrating to the latest versions. But the customers don’t always have the time and budget to migrate.
I don’t tell the customers to migrate just to be on the latest version. But to be ready for the future, I would suggest migrating to .NET Core. You don’t need to migrate your whole solution at once. You can for example start by migrating an existing library to the .NET Standard. That’s for me a big advantage. That way you can quickly migrate base libraries. It’s also a good practice to separate business code from your views if you have an old code base. I know the migrations I did in the past would be a lot easier if .NET Core and especially .NET Standard was available.
New projects I would create in .NET Core.
And remember that .NET Standard is, according MSDN: One Library to Rule Them All.
Summary of the advantages
- Cross Platform
- .NET Core is open source
- You can host ASP .NET Core applications on Linux for example (cheaper hosting costs)
- .NET Framework 4.8 will be last major release of .NET Framework
- You can run multiple .NET versions side-by-side
- Upgrade cycles
Summary of the possible disadvantages
- With .NET Framework you have more tools (APIs) then with .NET Core. But this will certainly change in the future.
- Not all libraries are .NET Core
- Windows workflow is not ported
- WCF is not supported. Migration would take 3 years
- NET Core Web APIs or gRPC (Google RPC, which provides cross platform and cross programming language contract-based RPCs) are the suggested replacements.
- Webforms are not supported (Blazor is the suggested replacement)
- Latest release .NET Framework 4.8
- Linked to IIS
- Not gaining anything
What I didn’t cover in this article is that we also must take our automatic deployment into account. If you migrate you project, you must keep that in mind.
.NET Core 3.0
This year (September / November) .NET Core 3.0 will be released. The biggest change is that it will desktop support (winforms / WPF) and C#8
.NET 5 and beyond
In the future we will have just one .NET (Windows, IOS, Linux, Android, …). The release is scheduled for November 2020. For more info: https://devblogs.microsoft.com/dotnet/introducing-net-5/
So, with this knowledge I suggest everybody prepare for migration to be future proof.
Written by Werner Kellens