I recently bought a computer with an ARM processor and started exploring its potential for .NET development. Right off the bat, I encountered some issues related to LocalDB and SQL Server. In this article, I’ll explain how I mitigated these problems using Docker and a specialized version of SQL Server designed for resource-constrained environments: Azure SQL Edge.
LocalDB on ARM problem
Currently, there is no support for LocalDB or SQL Server, whether the full or express version, on ARM in Windows. When I tried running EF Core with a migration, I received an error message stating that it was unable to load SQLUserInstance.dll
.
My current setup
Initial Attempt with LocalDB
This is the connection string for a basic .NET project using LocalDB:
Solution: Run SQL Server on Linux via Docker
Azure SQL Edge is a streamlined version of SQL Server focused on edge computing and IoT. Although the documentation states that Azure SQL Edge no longer supports arm64 platforms, inspecting the image reveals that it is multi-platform.
Since it is multi-platform, I can run this image without the performance issues that would occur if the container were running in emulation mode.
To inspect the Docker image run docker manifest inspect mcr.microsoft.com/azure-sql-edge
.
Setting Up SQL Server with Docker
Prerequisite
Ensure WSL and Docker Desktop are installed on your system.
Step 1: Download the Azure SQL Edge image
Run the following command to pull the image:
Step 2: Start the Container
You can start the container with a simple docker run command, but I prefer using a Docker Compose file for better configuration management.
Here’s an example docker-compose.yml
file:
In the same folder where you saved the docker-compose.yml
file, start the container with the command docker-compose up -d
in the terminal.
Testing the Connection
Use your preferred tool to test the connection. For example, with SQL Server Management Studio (SSMS):
If the connection is successful, you’re ready to proceed.
Updating the Connection String
Update your application’s connection string to point to the new database. For example:
Applying Migrations
Run the following command to apply the EF migrations:
Common Error: Certificate Issue
You might encounter an error related to SSL certificates.
To resolve this, update the connection string to include TrustServerCertificate=True
:
Run the migration again:
Success!
The .NET application is now set up to use a containerized SQL Server database on an ARM processor. While the Azure SQL Edge provides a practical solution for development today, you can use it as a temporary workaround until Microsoft addresses the compatibility issues with SQL Server and LocalDB on ARM platforms.
Start the conversation!