c# – How to avoid CRUD and layered architectures in REST backends?

I’m creating a .Net 5 API backend and use EF Core for the database part. The simple CRUD way I know:

  • API layer calling a command or query from the application layer using MediatR
  • Application layer calling CRUD actions from repository interfaces

As we all know the CRUD actions are struggling with the real world problems. I would like to move away from the repository CRUD pattern and focus on the commands/queries as a single complex unit.

I think I should not mix the business logic with the persistence logic. But how should I structure the different parts then? Should one command/query contain everything it needs? This would break up the reusability. But otherwise I think I will fall back to CRUD based interfaces.

I read about Event Sourcing but for now I’m more interested in a solution not using it :]