I have an MVC Core application that works on my machine, where SQLEXPRESS is not a named instance. When I deploy it to IIS 7.5 on a remote machine, where it is a named instance, without changing the connection string:
"Server=localhost;Database=QuickShare;Trusted_Connection=True;MultipleActiveResultSets=true"
I get the following error:
SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Then I correct the connection string for the nameD instance:
"Server=localhost.\SQLEXPRESS;Database=QuickShare;Trusted_Connection=True;MultipleActiveResultSets=true"
I get the following error:
ArgumentNullException: Value cannot be null. Parameter name: connectionString
In the stack trace on the developer error page, highlighted is the following line from Startup.cs
:
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
How does changing only the connection string go from an expected connection exception to a null parameter exception?