title: Sqlite ExecuteScalar throwing NullReferenceExcpetion
body: <p>I have a custom written DB provider. When I run my tests, they're breaking on the <code>ExecuteScalar</code> command with a <code>NullReferenceException</code>. What might I be missing here? I've read that some people have a MultiThreading issue, but I don't "think" that's what I'm running into.</p>
  
  <p>Here's my GetOpenConnection method</p>
  
  <pre><code>public SqliteConnection GetOpenConnection()
  {
      var connection = new SqliteConnection(_connectionString);
      if (connection == null) throw new Exception("Could not create a database connection.");
  
      connection.Open();
  
      return connection;
  }
  </code></pre>
  
  <p>And the ExecuteScalar method </p>
  
  <pre><code>public TKey ExecuteScalar&lt;TKey&gt; ( string commandText, IDictionary&lt;string, object&gt; parameters )
  {
      using ( var connection = _connectionProvider.GetOpenConnection() )
      {
          using ( var command = connection.CreateCommand() )
          {
              command.CommandType = CommandType.Text;
              command.CommandText = commandText;
              foreach ( var parameter in parameters )
              {
                  command.Parameters.Add( new SqliteParameter( parameter.Key, parameter.Value ?? DBNull.Value ) );
              }
  
              // BREAKING HERE
              return ( TKey )command.ExecuteScalar();
          }
      }
  }
  </code></pre>
  
  <p>And this is the method that's calling the <code>ExecuteScalar</code></p>
  
  <pre><code>private const string CheckTableExists = "SELECT name FROM sqlite_master WHERE type='table' AND name='{0}'";
  
  public bool CheckIfTableExists ( string tableName )
  {
      var exists = ExecuteScalar&lt;int&gt;( string.Format( CheckTableExists, tableName ) ) == 1;
      return exists;
  }
  </code></pre>
  
  <p>I put a break point on it, and try to step into it.. .and the code just breaks and throws the exception... I can't track it down</p>