title: How should one maintain a database connection in an ASP.NET MVC application?
body: <p>I'm not using LINQ-to-SQL or Entity Framework bits in a web app, and have currently been using something like this (this is for a class project):</p>
  
  <pre><code>using System.Data;
  using System.Data.SqlClient;
  
  namespace StackOverflowClone.Models
  {
      public class Database
      {
          public static SqlConnection ActiveConnection { get; private set; }
  
          static Database()
          {
              ActiveConnection = new SqlConnection(
                  "Data Source=********.database.windows.net;" +
                  "Initial Catalog=EECS341;Uid=*****;Pwd=*******;" + 
                  "MultipleActiveResultSets=True;");
              ActiveConnection.Open();
          }
      }
  }
  </code></pre>
  
  <p>However this seems to cause threading issues because the static initializer runs once per server process, rather than once per request.</p>
  
  <p>Does the framework provide a built in method of handling this or should I just have a function that coughs up database connections new'd up each time?</p>