Exploring the models for database mapping
When creating services, different models can be used for the database, the functionality, and the APIs. The database layer might have different requirements than the other layers. When creating a monolithic application, this usually is the case, but it also means that while maintaining the application and adding a field, all the different layers need to be touched and updated. When creating microservices with smaller scopes, there’s a good chance to use the same model with the database, the functionality of the application, and the APIs. This not only reduces maintenance costs but also improves performance in that not every layer creates new instances and copies the values around.
With the sample application, the Game
and Move
types with their generic counterparts created in the previous chapter are not that simple, but it’s possible to use them directly with EF Core.
Let’s look at the models and what must be mapped...