It all depends. A wise man once said:
abstracts [should be] owned by the upper/policy layers
You might have read Mark Seemann's excellent book Dependency Injection in .NET, where he show cases this principle (see section 2.2 in the 1st edition and chapter 3 in the 2nd edition) with an example for the exact scenario you are describing (i.e. repository interface as part of the Domain Layer).
The most important argument that Mark Seemann gives for doing this is because it allows you to replace your Data Access technology with a different one, which might be a more likely scenario you might think, especially considering the world we live in right now where everything moves to the cloud and in the cloud you might not have (or want) to use the same Data Access technology.
But there are other reasons for wanting to isolate your core layer (the Domain layer) from the rest of the application and let everything depend on the most important part of the application.
One thing that comes to mind is to make it impossible for developers to accidentally couple this layer to Volatile (or impure) parts of the system that make it harder to change later on. The dependency on your Data Access functionality is one obvious thing, because it can make testing harder, but also think about accidentally coupling your Domain layer to System.Web
, making it possible for developers to use HttpContext
in that part of the system. Chances are quite big that once you have a dependency (from Domain layer to Data Access layer), it will become much harder to invert over time.
On the other hand, whether this high degree of isolation is beneficial to your application does obviously depends on a lot of factors. And especially when the application is already designed this way, it might be better to focus your attention on other improvements first.
Don't forget that the most important part of Dependency Inversion Principle (DIP) and Dependency Injection (DI) is that classes depend on abstractions. This enables loose coupling, and loose coupling improves maintainability. Since those developers already practice DI, they are already in a good place.
A typical improvement that I make is to get rid of most of the repositories, and introduce higher-level concepts such as a generic abstraction over business operations, a generic abstraction over queries and sometimes domain events. This limits the use of repositories to inside the Domain layer. When introducing this, this is a great moment to invert the dependencies for new (or migrated) code that uses these concepts instead of I[EntityName]Repository
and I[EntityName]Service
abstractions that are typically in violation of most of the SOLID principles anyway.
Another thing I advocate is to prevent the core layer of your application from having a dependency on a logger abstraction of some third party logging library. This again boils down to the DIP that states that the application should own the abstractions, which is not the case when the application depends on a third party abstraction. That's why I promote things like this.