public static DbConnection GetUnderlyingConnection(this DbContext context, BulkConfig config) { var connection = context.Database.GetDbConnection(); if (config?.UnderlyingConnection != null) { connection = config.UnderlyingConnection(connection); } return(connection); }