3

Writing Data to Relational and NoSQL Databases

After creating the first implementation of the service using minimal APIs, we build on that to read and write to databases. In this chapter, we will replace the in-memory repository built in Chapter 2 using Entity Framework Core (EF Core) to access a relational database – Microsoft SQL Server – and an Azure Cosmos DB NoSQL database using EF Core.

You’ll create two libraries to access these databases, create EF Core context classes, specify the mappings from model classes, and configure the minimal APIs service to use one or the other database. After adding these changes, the games will be persisted and you can continue game runs when the service is restarted.

In this chapter, you’ll be exploring ...

Get Pragmatic Microservices with C# and Azure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.