Taking gRPC further
Now let’s look at some more advanced topics like native AOT compilation support, getting metadata, adding deadlines, handling dates, times, and decimal types, adding interceptors, and handling exceptions and transient faults.
Improving a gRPC service with native AOT publish
.NET 8 introduces gRPC support for native AOT. But as you have just seen, it is not (yet) compatible with some parts of .NET like EF Core.
Let’s change our gRPC service to use the SQL client instead of EF Core. We will leave most of the EF Core code in the project so you can switch back if you want in the future, for example, if you upgrade to EF Core 9 and it supports native AOT:
- In the
Northwind.Grpc.Service
project, uncomment out the option to publish AOT and add a package reference for the SQL client, as shown in the following markup:<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.2" />
...