title: How to get a list of database names from a SQL Server instance using Entity Framework?
body: <p>I would like to use Entity Framework (EF) to query a SQL Server instance and return a list of database names on that instance.</p>
  
  <p>I can do this using the following code, but wondered if there was a way with EF?</p>
  
  <pre><code>   public static string[] GetDatabaseNames(SqlConnection masterConn)
      {
          List&lt;string&gt; databases = new List&lt;string&gt;();
  
          //  retrieve the name of all the databases from the sysdatabases table
          using (SqlCommand cmd = new SqlCommand("SELECT [name] FROM sysdatabases", masterConn))
          {
              using (SqlDataReader rdr = cmd.ExecuteReader())
              {
                  while (rdr.Read())
                  {
                      databases.Add((string)rdr["name"]);
                  }
              }
          }
  
          return databases.ToArray();
      }
  </code></pre>
  
  <p>I should mention that I am new to EF and its capabilities  / limitations.</p>