Possible source of error in creating master connection string
See original GitHub issueHello @Zaid-Ajaj. I am rewriting your code to the F# equivalent and I stumbled upon a problem with this line of code:
var connectionStringOfMaster = ConnectionString.Replace(databaseName, "master");
By change I tested this with a database name that was part of the Data Source name. I,e.
let connString = @"Data Source=VOXDB-PICURED01;Initial Catalog=PICURED;Persist Security Info=True;Integrated Security=SSPI;"
And obviously replacing PICURED with master yields a Data Source=VOXDB-master01
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
This operation requires a connection to the 'master' database
The error is: This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the ......
Read more >Troubleshoot common connection issues to Azure SQL ...
Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy to...
Read more >Connectionstring results in unwanted error · Issue #97780
"This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original ...
Read more >Connection to external SQL Server database
Connection String test failed: A network-related or instance-specific error occurred while establishing a connection to SQL Server.
Read more >SQL Connection Strings tips
The connection string is an expression that contains the parameters required for the applications to connect a database server.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I had a closer look at you’r code, but I think it is a simple string replace, only this method is used with the generated connection string that contains a random generated database name like: Data Source=VOXDB-PICURED01;Initial Catalog=ThrowawayDbfe50108b74;Integrated Security=True;Persist Security Info=True
So this will very unlikely be confused with the Data Source name.
I might try that, but don’t underestimate how rusty my C# language abilities are 😉.
@Zaid-Ajaj Looks great, thanks. FYI this is my F# translation: https://gist.github.com/halcwb/c7a1340d69c9d4dcd2c6f0cdda46ab7e.
Small detail, I don’t think you need to keep track of the original connection string. Just use the master connection string for that.