title: .NET Core: How can I set the connection string?
body: <p>I am trying to use Blazor's CRUD functions and following some article to do this. In the article, there is a part that I should put my connection in context file, but it doesn't say how to set the connection string.</p>
  
  <p>I put this code line in launchSettings.json:</p>
  
  <pre><code>{
    "ConnectionStrings": {
      "UserDatabase": "Server=DESKTOP-2K2A6GN;Database=Assignment4;Trusted_Connection=True;"
    },
    "iisSettings": {
      "windowsAuthentication": false,
      "anonymousAuthentication": true,
      "iisExpress": {
        "applicationUrl": "http://localhost:56244/",
        "sslPort": 0
      }
    },
    "profiles": {
      "IIS Express": {
        "commandName": "IISExpress",
        "launchBrowser": true,
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        }
      },
      "Assignment4.Server": {
        "commandName": "Project",
        "launchBrowser": true,
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "applicationUrl": "http://localhost:56248/"
      }
    }
  }
  </code></pre>
  
  <p>And I tried to add the connection string into the context file, but it didn't work.</p>
  
  <pre><code>public class UserContext : DbContext
      {
          public virtual DbSet&lt;User&gt; tblUser { get; set; }
  
          protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
          {
              if (!optionsBuilder.IsConfigured)
              {
                  optionsBuilder.UseSqlServer(@"UserDatabase");
              }
          }
      }
  </code></pre>