Skip to main content
Software Alchemy

The Art and Science of Software Development

Persistence, Tenancy, and the Data Model

In this blog entry we will evolve our solution and the data model behind it, so that we can begin to see how user requests and interactions operate against a multitenant system. We’ll start by refactoring the persistence interfaces and implementations to make the solution more scalable in a split-stack CQRS architecture. Alongside this change, I’ll show you how you can use both Dapper and Entity Framework Core inside a single transaction/unit of work. Then we’ll add some new EF Core entities corresponding to the tenants and customers of our SaaS product. Finally, we’ll perform some cleanup across the data model classes so that the Persistence layer is more robust.


This entry discusses some of the high-level concepts that are relevant to modern software architecture at a general level, namely monoliths vs. microservices, and multitenancy. I'll give some guidance as to what those mean, and how they are applied to this foundational concepts blog series and the accompanying demo application. In this and future blog entries I'll assume that you fall into a certain audience, namely individual entrepreneurs, small software startups, or developers/teams building new solutions within a larger organization. This information is still valuable if you are working on legacy systems or doing what we call brownfield development. However, the spirit of the information presented is most applicable to building new solutions from scratch, what is referred to as greenfield development.