It can make a difference for unit testing if you use IDbConnection and all other classes instead of specific classes.
Besides IOC and the like, I actually used DbFactoryProvider ( additional information ) several times to create my connections and other database related objects and read the provider through ConnectionString.
The main problem with the database material is that usually you cannot use only ANSI-SQL with the database, therefore, while you are separated from specific classes, your sql will not be migrated. (i / e limit in MySql or Over and Partition on Sql Server).
About DI / IOC with other things that were not related to the database, perfectly separate your classes and remove dependencies, and also help with unit testing, say, when you have a service that you work with. This is useful, even if not in the testing unit, when you are working against the service, and the other team is still developing the service, you can create a fake service that basically solves your problems (not all) so that you can work against anything before a real service is available.
There are many more examples, but working with services (database repository / web / authorization / whatever) is the first simplest added value.
source share