title: Error connecting to database using Linq
body: <p>I am trying to use linq2db and mysql to connect to my database, so, I have a simple connection like so:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using LinqToDB;
  using LinqToDB.Configuration;
  using LinqToDB.DataProvider;
  using MySql.Data.MySqlClient;
  using twitter.Properties;
  using DataModels;
  
  namespace twitter.classes
  {
      class core
      {
          public static string DatabaseHost
          {
              get { return Settings.Default["databasehost"].ToString(); }
              set { Settings.Default["databasehost"] = value; }
          }
  
          public static string DatabaseUser
          {
              get { return Settings.Default["databaseuser"].ToString(); }
              set { Settings.Default["databaseuser"] = value; }
          }
  
          public static string DatabaseName
          {
              get { return Settings.Default["databasename"].ToString(); }
              set { Settings.Default["databasename"] = value; }
          }
  
          public static string DatabasePassword
          {
              get { return Settings.Default["databasepass"].ToString(); }
              set { Settings.Default["databasepass"] = value; }
          }
  
          public class ConnectionStringSettings : IConnectionStringSettings
          {
              public string ConnectionString { get; set; }
              public string Name { get; set; }
              public string ProviderName { get; set; }
              public bool IsGlobal =&gt; false;
          }
  
          public class MySettings : ILinqToDBSettings
          {
              public IEnumerable&lt;IDataProviderSettings&gt; DataProviders
              {
                  get { yield break; }
              }
  
              public string DefaultConfiguration =&gt; "Twitters"; // lets set your configuration as default, so you can call just new DataContext() or new DataConnection()
              public string DefaultDataProvider =&gt; ProviderName.MySql; // and set default database type
  
              private static IDataProvider GetDataProvider()
              {
                  return new LinqToDB.DataProvider.MySql.MySqlDataProvider();
              }
  
              public IEnumerable&lt;IConnectionStringSettings&gt; ConnectionStrings
              {
                  get
                  {
                      yield return
  
                          new ConnectionStringSettings
                          {
                              Name = "Twitters", // This is configuration name, you pass it to DataConnection constructor
                              ProviderName = ProviderName.MySql, // here we are setting database we are working with
                              ConnectionString = "server=" + DatabaseHost + "; database=" + DatabaseName + "" + ";user=" + DatabaseUser + "; password=" + DatabasePassword + ";",
                          };
                  }
              }
          }
  
          public class DbTwitters : LinqToDB.Data.DataConnection
          {
              public DbTwitters() : base("Twitters") { }
  
              public ITable&lt;Account&gt; Accounts { get { return GetTable&lt;Account&gt;(); } }
              public ITable&lt;Favorite&gt; Favorites { get { return GetTable&lt;Favorite&gt;(); } }
              public ITable&lt;Retweet&gt; Retweets { get { return GetTable&lt;Retweet&gt;(); } }
  
          }
  
          internal class MySqlDataReader
          {
          }
  
      }
  }
  </code></pre>
  
  <p>Which I am trying to use inside my main program to store information and connect to the database like so:</p>
  
  <pre><code>using (var db = new TwitterDB())
  {
      var query = from a in db.Accounts
                  select a;
  </code></pre>
  
  <p>Now, my problem is, when I am trying to connect to the database, my pgoram throws an error saying the following:</p>
  
  <p>an attempt to attach an auto-named database for file aspnetdb.mdf failed...</p>
  
  <p><a href="https://i.stack.imgur.com/YKI0U.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YKI0U.png" alt="enter image description here"></a></p>
  
  <p>My Tables.cs file exists, as you can see here;</p>
  
  <p><a href="https://i.stack.imgur.com/bQtXm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bQtXm.png" alt="enter image description here"></a></p>
  
  <p>I have the connection in the config file:</p>
  
  <pre><code>&lt;system.data&gt;
    &lt;DbProviderFactories&gt;
      &lt;remove invariant="MySql.Data.MySqlClient" /&gt;
      &lt;add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /&gt;
    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
  </code></pre>
  
  <p>How can I fix this error so I can connect to my database?</p>