What's new in .NET Core, ASP.NET Core and EF Core 2.1

What's new in .NET Core, ASP.NET Core and EF Core 2.1

Yesterday the Microsoft Teams have updated their roadmaps of .NET Core, ASP.NET Core and EF Core in focus of the next version 2.1:

.NET Core 2.1

Error output

Nothing to add to this tweet.

They made the StackTrace great again!

System.IO.Pipelines

Microsoft have worked on this namespace almost two years. It's based on the idea from GoLang's Channels and is named as Pipelines in the .NET world.

This is for me the most important update for .NET Core 2.1. IT offers new possibilities in focus of performance for all .NET Core applications.

The dark side is: you can only use this in .NET Core projects. This namespace is not part of the .NET standard.

Windows Compatibility Pack

For easier migration of your code to .NET Core, Microsoft now offers a Windows Compatibility Pack. Even special Windows based namespaces like System.Drawing or the Windows Eventlog are available!

Versioning

With .NET Core 2.1 you will be able to run all minor versions of the same major version.

This means you can run .NET Core 2.0 application on .NET Core 2.1, 2.3 .. and all later runtime versions.

ASP.NET Core 2.1

ASP.NET Core 2.1 really get a lot of great new features!

Microsoft.AspNetCore.App

In the past we got Microsoft.AspNetCore.All, a meta package with all ASP.NET Core related NuGet packages as default dependencies.

Now we have Microsoft.AspNetCore.App which only have the smallest subset of dependencies. All templates will be updated to thse Microsoft.AspNetCore.App instead of Microsoft.AspNetCore.All.

Microsoft.AspNetCore.All will still be the supported for the lifecycle of ASP.NET Core 2.x.

I really like the thinking of the smallest subset and you have to think about of what you add. I tried to avoid the *.All package so far and I am pretty sure the *.App way will be better and easier.

ActionResult

In the past it was like a generic return of APIs.

Before:

    [HttpGet("{id}")]
    public IActionResult GetPersonById(int id)
    {
		PersonModel person;
        if (!_personService.TryGetPersonById(id, out person))
        {
            return NotFound();
        }

		// Map always to an API model to not expose all properties
		PersonApiModel apiModel = _apiModelMapper.MapFrom(person);

        return Ok(apiModel);
    }

With 2.1:

    [HttpGet("{id}")]
    public ActionResult<PersonApiModel> GetPersonById(int id)
    {
		PersonModel person;
        if (!_personService.TryGetPersonById(id, out person))
        {
            return NotFound();
        }

		// Map always to an API model to not expose all properties
		PersonApiModel apiModel = _apiModelMapper.MapFrom(person);

        return Ok(apiModel);
    }

SignalR

SignalR is now ported to ASP.NET Core and their is no more dependency to jQuery anymore. Microsoft also have some samples for you here.

General Data Protection Regulation (GDPR)

They made a lot of changes of the cookie middleware to create GDPR-compliant ASP.NET Core applications. For example you now can mark a cookie as essential or as non-essential if the user does not accept your cookies.

Also some changes to the ability to create own encryption providers for ASP.NET Core identity data will help you to be (more) GDPR-compliant. But you still have to implement your own UI-dialogs to ask the user for cookie acceptance.

HTTPS

HTTPS is now on by default to have a more secure web. Also HTTPS is required for GDPR-compliance.

You now will have a developer certificate with the .NET Core SDK and Kestrel will listen to HTTPS by default, too. All project templates will be updated with HTTPS and HTTPS direction.

Kestrel

Kestrel now supports Socket Transport and HTTPS is added. Also Microsoft has abstracted the underlying libuv stuff to offer transport extensibility for future.

WebHooks

Now a lot of WebHook receivers are ported to ASP.NET Core 2.1

EF Core 2.1

GroupBy Statements

For me the most existing No-Go of EF Core 2.1: all GroupBy statements were executed in memory. ¯_(ツ)_/¯ This made EF Core 2.0 for almost every real world application absolutely useless....

This is fixed in EF Core 2.1 and now the most cases are translated to SQL GROUP BY clauses.

Lazy Loading

I was never a fan (and maybe never will be) of lazy loading because it often was like a black box. But now it is also implemented in EF Core with 2.1. For a lot of devs very important. No idea why ;-)

Transactions

EF Core 2.1 now has the ability to work with System.Transactions. This makes it easier to develop same database implementations for .NET Framework and .NET Core projects.

Release dates

Microsoft announced all releases of 2.1 for the first half of 2018.

Microsoft Announcements:

I cherry-picked the most important new features in my eyes in this blog post. You still should take a look into all roadmap articles of Microsoft with all new features!