title: Use SQlite and MySQL with entity framework
body: <p>In our application we use Database first with SQlite database.</p>
  <p>In the program we use this method to get entities</p>
  <pre><code>public static SidelDataStoreEntities CreateEntitiesForSpecificSqliteDatabaseName(string databaseName)
      {
          var connection = new EntityConnectionStringBuilder()
          {
              Metadata = metadata,
              Provider = &quot;System.Data.SQLite.EF6&quot;,
              ProviderConnectionString = new SqlConnectionStringBuilder() { DataSource = databaseName, }.ConnectionString,
          };
          sidelDataStoreEntities = new SidelDataStoreEntities(connection.ConnectionString);
          return sidelDataStoreEntities;
      }
  </code></pre>
  <p>Now we want be able to use also MySQL. It's exactly the same tables.
  We use this method to get entities.</p>
  <pre><code>    public static SidelDataStoreEntities CreateEntitiesForMySqlServer()
          {
              var connection = new EntityConnectionStringBuilder()
              {
                  Metadata = metadata,
                  Provider = &quot;MySql.Data.MySqlClient&quot;,
                  ProviderConnectionString = new MySqlConnectionStringBuilder()
                  {
                      Database = &quot;datastore&quot;,
                      Server = Settings.Default.DataBaseServer,
                      IntegratedSecurity = false,
                      UserID = GetUserId(),
                      Password = GetPassword()
                  }.ConnectionString,
              };
              sidelDataStoreEntities = new SidelDataStoreEntities(connection.ConnectionString);
              return sidelDataStoreEntities;
  }
  </code></pre>
  <p>In App.config we have</p>
  <pre><code>&lt;entityFramework&gt;
      &lt;providers&gt;
        &lt;provider invariantName=&quot;MySql.Data.MySqlClient&quot; type=&quot;MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.22.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d&quot;/&gt;
        &lt;provider invariantName=&quot;System.Data.SqlClient&quot; type=&quot;System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer&quot; /&gt;
        &lt;provider invariantName=&quot;System.Data.SQLite.EF6&quot; type=&quot;System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6&quot; /&gt;
        &lt;provider invariantName=&quot;System.Data.SQLite&quot; type=&quot;System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6&quot; /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
  </code></pre>
  <p>But when we use MySQL database we've got this message when we want to use entities</p>
  <blockquote>
  <p>System.InvalidCastException: 'Unable to cast object of type 'MySql.Data.MySqlClient.MySqlConnection' to type 'System.Data.SQLite.SQLiteConnection'.'</p>
  </blockquote>
  <p>The key seems to be the attribute</p>
  <blockquote>
  <p>[DbConfigurationType(typeof(MySqlEFConfiguration))]</p>
  </blockquote>
  <p>If we use it with MySql, we got another error because of &quot;sideldatastoremodelstorecontainer.&quot; added in table name</p>
  <blockquote>
  <ul>
  <li>
  <pre><code>InnerException  {&quot;Table 'datastore.sideldatastoremodelstorecontainer.databasemetadata' doesn't
  </code></pre>
  </li>
  </ul>
  <p>exist&quot;}   System.Exception {MySql.Data.MySqlClient.MySqlException}</p>
  </blockquote>
  <p>And this attribute generate runtime error if we use with SQlite database</p>
  <p>So we have 2 questions</p>
  <ul>
  <li>How to use the attribute only for MySQL db?</li>
  <li>For MySQL db, how to suppress additional charaters in table name</li>
  </ul>
  <p>Thanks for any help.</p>