After publishing our Blazor server application in .NET 6 Core, we are getting the following error when trying to connect to a remote SQL Server:
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: SNI_PN11, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
Our previous builds worked and now all of a sudden we can't get it to work even when reverting back to the older Nuget packages in use in the older, working versions.
We have reviewed the remote SQL Server for any changes and there has been any. The server is still functioning and still set to allow remote connections. It is also still accepting connections from other applications. Other applications are able to resolve to and connect to the server.
This is the connection string:
Server=<remoteserver>;Database=Test;Integrated Security=true;TrustServerCertificate=true;Trusted_Connection=True;MultipleActiveResultSets=true
This is the publishing profile:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<ProjectGuid>28c4e0f6-5f0e-422b-a235-1d1ee85e070d</ProjectGuid>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
This is the project file:
<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="Current">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>aspnet-MudBlazorStarter-ed025a1e-e1ac-4144-83c8-2ecb1a6e4c8b</UserSecretsId>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="6.0.25" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.25" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.16" />
<PackageReference Include="MudBlazor" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DatabaseTableExport\DatabaseTableExport.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
</Project>
UPDATE: We tried an older build of the application from November and it works. We compared the Nuget packages for a possible compatibility issue and they are the same. Next we tried a build from the day before we started experiencing the error and it works. We rebuilt that code and the new build gets the same error. Two builds with the same code and Nuget packages, but one can connect to the server and the the other cannot.