I'm using Entity Framework Core in my ASP.NET Core 6 application and it's having an issue launching when installed as a Windows service. The executable when published works when I launch it from the command line, but fails to launch when installed as a service.
I tried to configure it to run under all different types of accounts such as SYSTEM, NETWORK, and even my Windows AD account - but without any success. Every attempt is met with this error:
Microsoft.Data.SqlClient.SqlException (0x80131904): 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)
System.ComponentModel.Win32Exception (2): The system cannot find the file specified.
In an attempt to see how far along it's getting in DbConnectionPool.TryGetConnection I need to enable Event tracing for the SqlClient the code to pick up the tracing events available.
The issue is that that example has a manual creation of a SqlClientListener class and using it when performing data access to capture the traces. Is there anyway of doing something similar for EF Core since EF Core uses Microsoft.Data.SqlClient internally?
The built in message categories available via configuration only seem specific enough to EF Core and not the SqlClient internals it calls.