Implementing gRPC for an EF Core model
Now we will add a service for working with the Northwind database to the gRPC project.
Implementing the gRPC service
We will reference the EF Core model that you created in Chapter 3, Building Entity Models for SQL Server Using EF Core, then define a contract for the gRPC service using a .proto
file, and finally implement the service.
We will start with the Shippers
table because it is simple. Each shipper only has three properties, an int
and two string
values, and there are only three records in the table. Let’s go:
- In the
Northwind.Grpc.Service
project, add a project reference to the Northwind database context project, as shown in the following markup:<ItemGroup> <ProjectReference Include="..\..\Chapter03\Northwind.Common.DataContext .SqlServer\Northwind.Common.DataContext.SqlServer.csproj" /> </ItemGroup>
The
...Include
path must not have a line break.