I use the repository pattern and UnitOfWork. This is kept in a separate project together with my domain model. I realize it might be tempting for users to go to the DbContext directly and add i.e. a child of a aggregate root.
Should I mark everything internal except for repositories and UnitOfWork? The reason for asking is that I’ve not seen this done in any of the documentation, examples or even the subject addressed in what I’ve read so far.
Do not expose the
DbContextto your domain layer and UI layer. Your repository pattern implementation is a leaky abstraction.Domain Layer
Data Access layer