title: Scaffold-DbContext "Login Failed" "Error Number:4060,State:1,Class:11"
body: <p>My ASP.NET MVC core application should connect to an existing MSSQL LocalDB file via Entity Framework.</p>
  
  <p>Database-first development requires reverse-engineering the existing database.
  Following the instructions in the <a href="https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db" rel="nofollow noreferrer">official documentation</a>, I am running the following command in the NuGet Package Manager Console:</p>
  
  <pre><code>Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=DatabaseName;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
  </code></pre>
  
  <p>However I am getting </p>
  
  <pre><code>No design-time services were found.
  System.Data.SqlClient.SqlException (0x80131904): Cannot open database "DatabaseName" requested by the login. The login failed.
  Login failed for user 'MACHINE-NAME\UserName'.
     at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
  
  Error Number:4060,State:1,Class:11
  Cannot open database "DatabaseName" requested by the login. The login failed.
  Login failed for user 'MACHINE-NAME\UserName'.
  </code></pre>