Hello!
This is a continuation of the second article about onion architecture in the development of cross-platform applications.
Pragmatic Clean Architecture
This comprehensive course will teach you the system I use to ship production-ready applications using Clean Architecture. Learn how to apply the best practices of modern software architecture. It contains Everything You Need To Build Production-Ready Applications With Clean Architecture.
Infrastructure
We continue creating PizzaStore
.
In this article, we are moving to the outer layer, which will implement the data interfaces.
Because we develop a cross-platform application we'll create Infrastructure
projects for each application - Web and Mobile.
Let's start with the WebApp.
To do this, let's add the Class Library
project and name it PizzaStore.Infrastructure.WebApp.Data
.
This project will implement the Application
layer interfaces. MS SQL Server will be used as storage, with which we will interact through the Entity Framework Core.
The benefit of the separation is you can easily replace the Database, ORM Framework, e.g. MySQL and Dapper.
Therefore, we will add all the NuGet Microsoft.EntityFrameworkCore
packages to this project. We will also add the PizzaStore.Application
project reference to the project.
After that, add a new WebAppContext
class to the project:
We also need to implement our IPizzaRepository
:
The final step is registration the db connection:
For the Mobile application, the steps are the same. The difference is only in DB initialization:
In the next article, we'll create UI level: Onion architecture in the development of cross-platform applications. Part 4. UI