title: How to specify a username using connection string in Entity Framework
body: <p>My ASP.Net Core app keeps trying to login into database using a "default" username even though I specify a different user in a connection string, which I am using. That is I keep getting the same exception that says:</p>
  
  <p><em>An unhandled exception occurred while processing the request.
  SqlException: Cannot open database "testDB" requested by the login. The login failed.
  Login failed for user 'DESKTOP-555DDD\skorejen'</em>.</p>
  
  <p>Even though I am using a connection string that has a different username defined.</p>
  
  <p>How can I fix it so that my app logins with the connection-string specified username?</p>
  
  <p>Connection String:</p>
  
  <pre><code>{
    "ConnectionStrings": {
      "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=testDB;User Id=myusername;Trusted_Connection=True;"
    },
  </code></pre>
  
  <p>ASP.Net Core Startup.cs file:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
          {
               services.AddDbContext&lt;OrderContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
          }
  </code></pre>