/// <summary> /// Creates a connection to the LocalDB instance. /// </summary> /// <param name="instance">The SQL LocalDB instance to create a connection to.</param> /// <returns> /// An instance of <see cref="SqlConnection"/> that can be used to connect to the LocalDB instance. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="instance"/> is <see langword="null"/>. /// </exception> /// <exception cref="InvalidOperationException"> /// The SQL LocalDB instance specified by <paramref name="instance"/> is not running. /// </exception> public static SqlConnection CreateConnection(this ISqlLocalDbInstanceInfo instance) { SqlConnectionStringBuilder builder = instance.CreateConnectionStringBuilder(); return(new SqlConnection(builder.ConnectionString)); }