1

In the app settings JSON file I am passing through a connection string which contains the name of my server ' .\SQL2017 '

I recieve the following warning in error list when entering the server name verbaitam as so in the connection string

'Invalid escape sequence'

When I then run the 'dotnet ef database update' command in the terminal I get the error

An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Could not parse the JSON file.

When I take away the .\ from the connection string to remove the warning for 'Invalid escape sequence I get passed the error above and am then faced with the error

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 conf igured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I am sure that the rest of my connection string properties are correctly entered with no warnings but I am not sure how to format the server name in the connection string in a JSON format so that it can accept without any errors

1
  • Use forward-slash instead - ./SQL2017, or encode it - .%5CSQL2017 Commented Sep 27, 2021 at 15:53

1 Answer 1

3

Double the backslash to escape it:

.\\SQL2017

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.