Search code examples
asp.netsql-serverasp.net-corelocaldbsql-server-2017-express

Using SQL Server authentication with localdb


I have a web app (SPA) with React as front-end and ASP.NET Core as backend. It is working fine on my desktop using SQL Server 2017 localdb with Windows authentication.

I want to use SQL Server authentication with username and password because the app will be distributed among clients at different locations and we want to restrict the users from directly accessing the database for our business logic.

The connection string is embedded in the C# code in the datacontext.cs file so that they may not access the data of database on their machines.

The user should not be able to connect to the database using SQL Server Management Studio (SSMS) using Windows authentication (which is not intended).

Using SQL Server authentication in the connection string results in an error

login failed for the user ...

Some friends suggest to use SQL Server Express edition and "mixed mode" i.e. SQL Server and Windows authentication instead of localdb to resolve the issue.

Thanks in advance for your help.


Solution

  • Some friends suggest to use SQL Server Express edition and "mixed mode" i.e. SQL Server and Windows authentication

    Listen to your friends. "SQL Server authentication with username and password " is disabled unless you Change the Server Authentication Mode