Switching from SQLite to SQL Server?

0

I'm trying to simply switch from SQLite over to Microsoft SQL Server on a basic .NET 5.0 application for local testing purposes.

I'm on Windows 10 running a linux subshell on Visual Studio Code.

I've installed Microsoft SQL Server, and also the SQL Server Configuration Manager as well as SQL Server Management Studio.

I've created a database via SSMS named wmsDB.

And in my Visual Studio Code connection string I have the following:

"ConnectionStrings": {
    "DefaultConnection": "Server=DESKTOP-P24QHEM\\SQLEXPRESS;Database=wmsDB;Trusted_Connection=True;MultipleActiveResultSets=true"
}

Every time I run dotnet run and try to sign up via email and password I'm greeted with the below error:

fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
An error occurred using the connection to database 'wmsDB' on server 'DESKTOP-P24QHEM\SQLEXPRESS'.

fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'miniwms.Data.ApplicationDbContext'.

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: TCP Provider, error: 25 - Connection string is not valid)

I'm not sure what I'm doing wrong - I've tried a few variations of the server name that I was hoping would fix it but still I'm encountering this issue every time.

c#
sql
sql-server
asked on Stack Overflow Apr 2, 2021 by Zefiron • edited Apr 3, 2021 by marc_s

1 Answer

2

If you trying to connect from Linux, you'll have to use TCP/IP. By default SQLEXPRESS doesn't have it enabled. Use the SQL Server configuration manager to enable it and set the SQL instance to listen on a fixed port. Use 1433 as it's is the default if you don't have any other SQL Server instances installed.


User contributions licensed under CC BY-SA 3.0