Question: **This is my connection string**

```
{
  "Data": {
    "PhotoGalleryConnection": {
      "ConnectionString": "Server=WINDOWS-B7MJR5T\\SQLEXPRESS;User Id=sa;password=allah;Database=PhotoGallery;Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  }
}

```

**And I am facing this exception**

> 
> An exception of type 'System.Data.SqlClient.SqlException' occurred in
>  Microsoft.EntityFrameworkCore.dll but was not handled in user code
>  Additional information: Cannot open database "PhotoGallery" requested
>  by the login. The login failed.
> 
> 
>

Answer: 
It should work after You delete Trusted\_Connection=True; from connection string.

> 
> If you specify either Trusted\_Connection=True; or Integrated
>  Security=SSPI; or Integrated Security=true; in your connection string 
>  THEN (and only then) you have Windows Authentication happening. Any
>  user id= setting in the connection string will be ignored. Found in here: [When using Trusted\_Connection=true and SQL Server authentication, will this effect performance?](https://stackoverflow.com/questions/1642483/when-using-trusted-connection-true-and-sql-server-authentication-will-this-effe)
> 
> 
>
[![Please search service in window menu](https://i.stack.imgur.com/sSmro.png)](https://i.stack.imgur.com/sSmro.png)

Please search services in the window menu, it will show you the local services then go to SQL server services and refresh all, then go to the SQL server management studio and by using SQL authentication please provide username and password, you will be able to use the SQL server. for appsetting.json update, trusted\_connection is used for window authentication not for SQL server authentication by using username and password