Skip to content

Cannot connect to (localdb) from .NET Core except via Named Pipe on Windows 11 ARM #1441

Open

Description

@benday

Description

I'm trying to connect to SQL Server Express LocalDB from .NET Core 6 on Windows 11 ARM. If I use a connection string that refers to it using the instance name "Data Source=(localdb)\MSSQLLocalDB", it fails with the exception below. If I connect to it using a named pipe, it works.

Microsoft.Data.SqlClient.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: SNI_PN11, error: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.) ---> System.ComponentModel.Win32Exception: %1 is not a valid Win32 application.

I've created some simple MSTest unit tests to repro the problem. There are two test methods in the DatabaseConnectionFixture class that attempt to connect to LocalDB: one uses an ordinary connection string and the other uses a named pipe. On Windows 11 ARM, the ConnectToDatabase_ConnectionString() method fails. If I run this same code on Windows 11 x64, both tests pass.

Configuration

This is running on Windows 11 ARM in a Parallels VM on an M1 MacBook Pro. The OS Build # is 22509.1011. The dotnet core build is 6.0.100.

Activity

  1. JRahnama commented on Dec 22, 2021

    @JRahnama
    Contributor

    @benday, I have not looked into the repro you have provided or much in details just some quick notes, have you tried with ssms to see if that gets a connection? LocalDb can use two different connection strings.

    1. (localdb)\<Instance name> or (localdb)\.\<shared instance name> or (localdb)\.. Last one connects to default local db which is MSSQLLocalDB

    2. np:\.\pipe\LOCALDB#\tsql\query

    The first one should be working without any issues, but there is an open issue for second one #1395 and PR #1433 is made to address issue.

    One other problem with Instance pipe name is if its state is stopped you wont be able to get a connection from Instance pipe name. make sure you have ran SqlLocalDB start <instance name>
    image

  2. benday commented on Dec 23, 2021

    @benday
    Author

    @JRahnama -- Thanks for that input. I hit that named pipe issue you mentioned but did a workaround a while back by simply setting Encrypt=false in the connection string. Not ideal but good enough to allow me to connect via "np:". Put another way, no issues for me on the ARM/Named Pipe thing.

    I tried the default instance syntax "(localdb)." that you suggested and I'm still getting the same error. The repro repo that I posted actually ensures that the localdb instance is running before attempting to connect to it.

    Per your question about SSMS, SSMS doesn't install on Win11 ARM. But I can connect to localdb using SQL Server Object Explorer in VS2022 running on ARM. What's extra strange is that I can connect to localdb using an app I wrote for dotnet 5 that's published to the store. https://www.microsoft.com/store/productId/9P5DZ9KQC7GR

    I think there is something about native .NET6 apps trying to connect that doesn't work from ARM. But that same code works fine when it's run in x86/x64 emulation under ARM.

  3. JRahnama commented on Jan 5, 2022

    @JRahnama
    Contributor

    @benday is the app on net 5 using same username/password to get connection? If not, I would say you probably need to add user login to your localdb
    CREATE LOGIN [username goes here] FROM WINDOWS WITH DEFAULT_DATABASE=[master] and add related roles, but if net5 is working with same credentials that is a different story. Setting up the environment will take sometime.

    1. I created a VM for Windows 11
    2. Added VS2022 and SqlServer 2019
    3. Add a sample repro with ARM64 configuration for net6 TFW

    and everything worked as expected. maybe I need to have Windows 11 ARM. Did you try it from Windows 11 Insider Preview Build?

  4. benday commented on Jan 5, 2022

    @benday
    Author

    @JRahnama --

    Yes, you'll definitely need a win11 arm machine to test this. As stated in the original bug report, everything works as expected on win11 on Intel x64. It fails on arm.

    Regarding the .net5 app running on win11 arm, I was connecting using "trusted connection=true" and that oddly worked fine.

  5. JRahnama commented on Jan 10, 2022

    @JRahnama
    Contributor

    @benday can you try adding AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", true); in your application to enforce Managed SNI usage to see the behavior?

  6. JRahnama commented on Jan 11, 2022

    @JRahnama
    Contributor

    One more question here can you run dumpbin.exe /headers SqlUserInstance.dll in the path of C:\Program Files\Microsoft SQL Server\150\LocalDB\Binn also check Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Local DB\Installed Versions\15.0 in the registry to see if the path is correctly installed?

  7. eolamisan commented on Jan 13, 2022

    @eolamisan

    I am having similar issue with .net 6.0 on regular intel dev laptop connecting to (localdb)\instancename in IIS.

    Does not work

    (localdb)\instancename

    Works

    np:\.\pipe\LOCALDB#FA0859AB\tsql\query

    Exception

    System.Data.Entity.Core.EntityException: The underlying provider failed on Open.
    ---> System.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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
    at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
    --- End of stack trace from previous location ---
    at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass4_0.<b__0>d.MoveNext()
    --- End of stack trace from previous location ---
    at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.ExecuteAsyncImplementation[TResult](Func1 func) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter.GetResult() at System.Data.Entity.Core.EntityClient.EntityConnection.OpenAsync(CancellationToken cancellationToken) ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:-1,State:0,Class:20 --- End of inner exception stack trace --- at System.Data.Entity.Core.EntityClient.EntityConnection.OpenAsync(CancellationToken cancellationToken) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter.GetResult() at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnectionAsync(Boolean shouldMonitorTransactions, CancellationToken cancellationToken) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter.GetResult() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransactionAsync[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess, CancellationToken cancellationToken)
    at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.ExecuteAsyncImplementation[TResult](Func1 func) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter1.GetResult()
    at System.Data.Entity.Core.Objects.ObjectQuery1.GetResultsAsync(Nullable1 forMergeOption, IDbExecutionStrategy executionStrategy, CancellationToken cancellationToken)
    at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter1.GetResult() at System.Data.Entity.Internal.LazyAsyncEnumerator1.FirstMoveNextAsync(CancellationToken cancellationToken)
    at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ForEachAsync[T](IDbAsyncEnumerator1 enumerator, Action1 action, CancellationToken cancellationToken)

    Configuration

    Processor Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz
    Installed RAM 32.0 GB (31.6 GB usable)
    System type 64-bit operating system, x64-based processor

    Edition Windows 10 Enterprise
    Version 20H2
    Installed on ‎12/‎20/‎2020
    OS build 19042.1415
    Experience Windows Feature Experience Pack 120.2212.3920.0

    Should I create a separate ticket?

  8. eolamisan commented on Jan 13, 2022

    @eolamisan

    I am having similar issue with .net 6.0 on regular intel dev laptop connecting to (localdb)\instancename.

    Does not work

    (localdb)\instancename

    Works

    np:.\pipe\LOCALDB#FA0859AB\tsql\query

    Exception

    System.Data.Entity.Core.EntityException: The underlying provider failed on Open.
    ---> System.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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
    at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
    --- End of stack trace from previous location ---
    at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass4_0.<b__0>d.MoveNext()
    --- End of stack trace from previous location ---
    at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.ExecuteAsyncImplementation[TResult](Func1 func) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter.GetResult() at System.Data.Entity.Core.EntityClient.EntityConnection.OpenAsync(CancellationToken cancellationToken) ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:-1,State:0,Class:20 --- End of inner exception stack trace --- at System.Data.Entity.Core.EntityClient.EntityConnection.OpenAsync(CancellationToken cancellationToken) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter.GetResult() at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnectionAsync(Boolean shouldMonitorTransactions, CancellationToken cancellationToken) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter.GetResult() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransactionAsync[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess, CancellationToken cancellationToken)
    at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.ExecuteAsyncImplementation[TResult](Func1 func) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter1.GetResult()
    at System.Data.Entity.Core.Objects.ObjectQuery1.GetResultsAsync(Nullable1 forMergeOption, IDbExecutionStrategy executionStrategy, CancellationToken cancellationToken)
    at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter1.GetResult() at System.Data.Entity.Internal.LazyAsyncEnumerator1.FirstMoveNextAsync(CancellationToken cancellationToken)
    at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ForEachAsync[T](IDbAsyncEnumerator1 enumerator, Action1 action, CancellationToken cancellationToken)

    Configuration

    Processor Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz Installed RAM 32.0 GB (31.6 GB usable) System type 64-bit operating system, x64-based processor

    Edition Windows 10 Enterprise Version 20H2 Installed on ‎12/‎20/‎2020 OS build 19042.1415 Experience Windows Feature Experience Pack 120.2212.3920.0

    Should I create a separate ticket?

    For some reason setting this flag:

    setProfileEnvironment="true"

    in this is file:

    C:\Windows\System32\inetsrv\config\applicationHost.config

    fixed it for me.

    Is this the recommended approach?

    Source:
    https://stackoverflow.com/questions/15491388/iis-applicationhost-setenvironment-attribute

  9. benday commented on Jan 14, 2022

    @benday
    Author

    One more question here can you run dumpbin.exe /headers SqlUserInstance.dll in the path of C:\Program Files\Microsoft SQL Server\150\LocalDB\Binn also check Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Local DB\Installed Versions\15.0 in the registry to see if the path is correctly installed?

    Here's the output from dumpbin:
    dumpbin-output.txt

  10. benday commented on Jan 14, 2022

    @benday
    Author

    I added a new test to the sample repo that adds that UseManagedNetworkingOnWindows call. The test still fails but it gives a different error message. The new error message is:

    System.Exception: Cannot connect to SQL Server Browser. Ensure SQL Server Browser has been started. ---> System.Net.Sockets.SocketException: No such host is known.
    Stack Trace:
    at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch)
    at System.Net.Dns.GetHostAddresses(String hostNameOrAddress, AddressFamily family)
    at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
    at System.Net.Sockets.UdpClient.GetEndpoint(String hostname, Int32 port)
    at System.Net.Sockets.UdpClient.SendAsync(Byte[] datagram, Int32 bytes, String hostname, Int32 port)
    at Microsoft.Data.SqlClient.SNI.SSRP.SendUDPRequest(String browserHostname, Int32 port, Byte[] requestPacket)
    at Microsoft.Data.SqlClient.SNI.SSRP.GetPortByInstanceName(String browserHostName, String instanceName)
    --- End of inner exception stack trace ---
    at Microsoft.Data.SqlClient.SNI.SSRP.GetPortByInstanceName(String browserHostName, String instanceName)
    at Microsoft.Data.SqlClient.SNI.SNIProxy.CreateTcpHandle(DataSource details, Int64 timerExpire, Boolean parallel, SqlConnectionIPAddressPreference ipPreference, String cachedFQDN, SQLDNSInfo& pendingDNSInfo)
    at Microsoft.Data.SqlClient.SNI.SNIProxy.CreateConnectionHandle(String fullServerName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[][]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, Boolean isIntegratedSecurity, SqlConnectionIPAddressPreference ipPreference, String cachedFQDN, SQLDNSInfo& pendingDNSInfo)
    at Microsoft.Data.SqlClient.SNI.TdsParserStateObjectManaged.CreatePhysicalSNIHandle(String serverName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[][]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, SqlConnectionIPAddressPreference iPAddressPreference, String cachedFQDN, SQLDNSInfo& pendingDNSInfo, Boolean isIntegratedSecurity)
    at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
    at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
    at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
    at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
    at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)
    at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
    at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
    at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
    at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
    at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
    at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
    at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
    at Microsoft.Data.SqlClient.SqlConnection.Open()
    at Benday.ArmDemo1.UnitTests.DatabaseConnectionFixture.Connect(String connstr) in c:\code\benday-inc\Benday.ArmDemo1\test\Benday.ArmDemo1.UnitTests\DatabaseConnectionFixture.cs:line 84
    at Benday.ArmDemo1.UnitTests.DatabaseConnectionFixture.ConnectToDatabase_ConnectionString_LocalDb_NamedInstance_UseManagedNetworkingOnWindows() in c:\code\benday-inc\Benday.ArmDemo1\test\Benday.ArmDemo1.UnitTests\DatabaseConnectionFixture.cs:line 41

  11. Xenyr commented on Jan 18, 2022

    @Xenyr

    Just wanted to report that this issue also concerns a native Windows 11 ARM installation on a Surface Pro X. Yet having troubles to install SQL Server 2019 at all (SQL Server Express, SQL Server Express Advanced and SSMS won't install without errors), the SQL Server 2019 LocalDB installation somehow manages to get through successfully. However, trying to access the local database via connection string (localdb)\MSSQLLocalDB as part of developing a Blazor WASM application gave me exactly the same error as in the original post (provider: SNI_PN11, error: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry).

    Developing using VS Code, I installed the SQL server extension for VS Code (https://docs.microsoft.com/en-us/sql/tools/visual-studio-code/sql-server-develop-use-vscode). Interestingly enough, trying to access the LocalDB via connection string using this extension succeeds on ARM, even starting the database instance if previously stopped. I verified this behaviour calling sqllocaldb info mssqllocaldb before and after accessing the database using the SQL server extension, which gave me an Instance: Stopped with no instance pipe name formerly and an Instance: Running alongside an instance pipe name afterwards.

    The Microsoft Surface Pro X has been configurated with a Microsoft SQ2 Processor and 16 GB RAM, running Windows 11 Build 22000.434 on arm64.

  12. ErikEJ commented on Jan 18, 2022

    @ErikEJ
    Contributor

    @Xenyr I think it should be: (localdb)\MSSQLLocalDB

  13. Xenyr commented on Jan 18, 2022

    @Xenyr

    @Xenyr I think it should be: (localdb)\MSSQLLocalDB

    Absolutely, sorry for that typo. I had tested it with the backslash back then and therefore edited my comment.

  14. shwelc2 commented on Jun 27, 2022

    @shwelc2

    I am experiencing the same issue with Windows 11 Arm/EF 6.06 /Visual Studio 2022 and localDB. I can connect to localdb in SSMS and also visual studio server explorer, but running migrations (update-database) always gives an error about being unable to connect to localdb. I also tried a clean install of the new Visual Studio 2022 Preview (arm) thinking this would resolve it, but the issue is still there.

    "DefaultConnection": "Server=(localdb)\mssqllocaldb;Database=aspnet-demo6-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true"

    Error Number:193,State:0,Class:20
    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: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.)

  15. shwelc2 commented on Jun 27, 2022

    @shwelc2

    I am experiencing the same issue with Windows 11 Arm/EF 6.06 /Visual Studio 2022 and localDB. I can connect to localdb in SSMS and also visual studio server explorer, but running migrations (update-database) always gives an error about being unable to connect to localdb. I also tried a clean install of the new Visual Studio 2022 Preview (arm) thinking this would resolve it, but the issue is still there.

    "DefaultConnection": "Server=(localdb)\mssqllocaldb;Database=aspnet-demo6-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true"

    Error Number:193,State:0,Class:20 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: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.)

    Should have added also
    Edition Windows 11 Enterprise
    Version 22H2
    Installed on ‎6/‎10/‎2022
    OS build 22621.160
    Experience Windows Feature Experience Pack 1000.22632.1000.0

  16. 11 remaining items

  17. Meligy commented on Apr 19, 2024

    @Meligy

    I second @jbogard findings. I had a .NET Framework app (.NET Framework 4.8) that worked just fine with Local DB, then after migrating it to .NET Core (.NET 8 actually), it started showing errors about connecting. Same connection string and everything.

    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: SQL Network Interfaces, error: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.)

  18. danieltharris commented on Aug 21, 2024

    @danieltharris

    Are there plans to remedy this?

    I have the same issue. I'm using surface pro x (sq1). Here is my solution to this issue. Please switch the platform to x64 or x86. Don't use anycpu for your project on ARM64 or you can't use LocalDB. This is just a temporary solution. I hope SQLUserInstance.dll can support native ARM64.
    image

    I'm using a Mac and don't have the option for x86 or x64 ... did you create a new configuration or does VS show those on the Surface?

    LocalDB isn't available for Mac - Are you running Local DB in Parallels and connecting to it from the Mac? On Mac an alternative that's worked for me is to run SQL Edge in Docker, works well for development purposes on my M3 Pro MBP (and was also fine on M1 MBA and M1 Pro MBP in the past)

  19. danieltharris commented on Aug 21, 2024

    @danieltharris

    @JRahnama is a fix for this issue planned or will localdb remain unsupported on Windows on ARM devices? It would be useful to have this available to avoid having to run alternatives such as SQL Edge in Docker - Especially since the rest of the modern .NET toolchain is now ARM Native (I think Azure functions are still an issue, but web and mobile has been a great experience so far)

  20. shwelc2 commented on Aug 21, 2024

    @shwelc2

    I got around this on my Mac Windows/Arm VM just using these alternative install scripts. The SQL express or any of the normal modern SQL servers run fine for me, I didn't try the native localdb but it may work also. You can just install the SQL server developer version and it should work.

    https://github.com/jimm98y/MSSQLEXPRESS-M1-Install

    I also did this as well prior so enable visual studio to connect using the arm64 dll for sql client.

    1. Downloading the Microsoft.Data.SqlClient.SNI package in NuGet.

    2. Copying Microsoft.Data.SqlClient.SNI.arm64.dll within build\net462 into C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\DAC (ensuring the version I copied across matched the version reported by Microsoft.Data.SqlClient.SNI.x64.dll).

    3. Restarting Visual Studio and testing connections.
      Upon restart, this enabled connections to my SQL Server Express instance running on the host within a Docker container. It seems to work for me (so far!) so I'm hoping it does for you too.

  21. LouisGordon commented on Aug 21, 2024

    @LouisGordon

    I worked around the issue by creating a SQL alias for the localdb named pipes connection and keeping that up to date (with the latest named pipes value for the localdb instance) via a scheduled task. Then your connection string server becomes LocalDbAlias, which is good enough for me.

    https://dev.to/louisgordon/localdb-dev-on-windows11-arm-cm3

  22. jbogard commented on Aug 21, 2024

    @jbogard

    I got around this on my Mac Windows/Arm VM just using these alternative install scripts. The SQL express or any of the normal modern SQL servers run fine for me, I didn't try the native localdb but it may work also. You can just install the SQL server developer version and it should work.

    https://github.com/jimm98y/MSSQLEXPRESS-M1-Install

    I also did this as well prior so enable visual studio to connect using the arm64 dll for sql client.

    1. Downloading the Microsoft.Data.SqlClient.SNI package in NuGet.
    2. Copying Microsoft.Data.SqlClient.SNI.arm64.dll within build\net462 into C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\DAC (ensuring the version I copied across matched the version reported by Microsoft.Data.SqlClient.SNI.x64.dll).
    3. Restarting Visual Studio and testing connections.
      Upon restart, this enabled connections to my SQL Server Express instance running on the host within a Docker container. It seems to work for me (so far!) so I'm hoping it does for you too.

    Just an FYI, I went this route as well to get "normal" SQL working, but it doesn't work for SQL Local DB. Unfortunately.

  23. michelemottini commented on Sep 18, 2024

    @michelemottini

    I am having the same issue - using Microsoft Surface Pro 11 with Windows 11. I have been able to work around it building as x64 but cannot see LocalDB from Visual Studio itself.

  24. added
    External 🔗
    on May 23, 2025
  25. moved this from To triage to Backlog in SqlClient Boardon Jan 8, 2026
  26. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  27. github-actions commented on Sep 17, 2026

    @github-actions

    @-

    Generated by SqlClient Issue Auto-Triage for #1441 · copilot · auto · 123.4 AIC · ⌖ 14.3 AIC · ⊞ 11.9K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    External 🔗

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions