My Asp.Net Razor C# project has a database connection string, and I can't figure out what it's connecting to.
The project has a reference to EntityFramework, and Microsoft SQL, so I'm assuming it's a Microsoft SQL database, somewhere.
The connection string is of the form:
DataSource="ABCDEF"; Initial Catalog="xyzzy"; Persist Security Info=True; ID=zzyzx; Password=uvwxyz"
The "DataSource" is what stumps me. It's not an environment variable, which is what it looks like. A search of the entire project shows this is the only place it is referenced.
In Visual Studio 2019 I open "SQL Server Object Explorer". It lists 3 (LocalDB) databases, none of which are the one. A 4th line has a folder symbol that says "Projects - MyProject" (substitute the actual project name for "MyProject"). That appears to be an empty folder.
Yet the program is definitely connecting to something and pulling data from it. I just can't figure out where it's getting it from.
How can I find out where this database is? How can I examine this database?
string databaseName = context.Database.Connection.Database;
by applying the above with the relevant IP address of you.
<connectionStrings> <add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/> </connectionStrings>
you may find the data source name "ABCDEF" there. You can then select that connection and go to config and get details as to where the source of the database is and what database it connects to