Well ... there is always this:
Debugger.IsAttached Property (System.Diagnostics) | Microsoft Docs[
^] which tells your code if a debugger is there.
But ... I'd rather have the app running the same code in release and debug: have a single connection string in your app.config and edit it for the release version(s).
Since you probably don't know what the release connection string will be anyway (it can easily be different for each user as they can have different permissions on the DB, or access different servers) this is probably the safest course.
When you run your app, you check if a config file exists, and create a default one if not - getting the connection string filled in then.