I'm building REST APIs with ASP.NET Core and Entity Framework Core with a database-first approach with clean architecture.
My database is already created and maintained by a DBA team - that's why I need to use Entity Framework Core with a database-first approach, and we need to do reverse engineering using the
Scaffold-DbContext command in the infrastructure layer.
With clean architecture, entities should be placed in
Core layer separate from the infrastructure layer so how we will do that and how to resolve your
DbContext as an interface.
I see two options:
You accept the dependency to the EF, put the generated entities into your core project and so accept the violation to clean architecture.
You create your own entities in Core project without dependencies to EF and use repository pattern to "map" between your entities and those from EF.
Alternative 1 is simple and cheap. Alternative 2 gives you independence from EF and some abstraction to your dba team. Choose based on what is more important for your project.