erro in command: dotnet-ef database update in linux

niltongc 1 Reputation point
2022-10-08T14:06:09.617+00:00

After migrations, I try to run the command:

dotnet-ef database update  

The following error occurs:

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  

OS: Linux Mint 20.3

In appsettings.Development.json:

"ConnectionStrings": {  
    "ConexaoPadrao": "Server=localhost\\sqlexpress; Initial Catalog=Agenda; Integrated Security=True"  
  }  

Can someone help me?

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
701 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,872 questions
Skype for Business Linux
Skype for Business Linux
Skype for Business: A Microsoft communications service that provides communications capabilities across presence, instant messaging, audio/video calling, and an online meeting experience that includes audio, video, and web conferencing.Linux: A family of open-source Unix-like operating systems.
456 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Olaf Helper 41,021 Reputation points
    2022-10-10T06:00:07.633+00:00

    Server=localhost\sqlexpress

    Localhost? It's a SQL Server, not a webserver. Use the right server name.

    0 comments No comments

  2. niltongc 1 Reputation point
    2022-10-10T22:48:17.837+00:00

    I got it with this change:

    "ConnectionStrings": {  
        "ConexaoPadrao": "Server=localhost;Database=Agenda;User Id=sa;Password=YourPassword;"  
          
      }  
    
    0 comments No comments

  3. Dan Guzman 9,211 Reputation points
    2022-10-10T22:51:08.75+00:00

    SQL Server on Linux does not support named instances. That's why it worked after you removed the instance name (SQLEXPRESS) from the connection string.

    0 comments No comments