I have a UWP app running successfully on my local machine connecting to a test database on the same machine. However, now I have to deploy the app to my work's Windows Server.
I cannot get the app to connect to the SQL Server database, which is running on the same machine as Windows Server. The error message is "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."
All the settings on the database seem to be correct. To test that, I created a simple .NET Core app to see if it could connect. It can. Here is the code:
using (SqlConnection connection = new SqlConnection("Data Source=ServerName,Portnumber;Initial Catalog=DatabaseName;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False")) ...
However, the UWP app, using the same connection string, cannot connect. Here is the relevant code. This code resides in a .Net Standard 2.0 project that uses EF Core 2.2.6. (I can't use EF Core 3.0 because it's not compatible with .Net Standard 2.0. I have to use .Net Standard 2.0, because 2.1 is not compatible with UWP.)
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Data Source=ServerName,Portnumber;Initial Catalog=DatabaseName;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); ...
I can also connect to the server successfully using SSMS.
In the UWP app's capability checkboxes, I have checked Enterprise Authentication and Private Networks.
In summary, I can connect via SSMS and a simple .NET Core app, but I my UWP app cannot connect. Can anyone point me in the right direction? Is this an issue with EFCore perhaps?