Bug #101236 Mysql.Data 8.0.26 - Entity framework
Submitted: 20 Oct 2020 8:30 Modified: 29 Jul 2021 18:18
Reporter: Matasci Sacha Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:8.0.22, 8.0.25, 8.0.26 OS:Any
Assigned to: CPU Architecture:Any
Tags: Visual Studio

[20 Oct 2020 8:30] Matasci Sacha
Description:
After updating to mysql.data 8.0.22 the schema is replicated.
In mysql.data 8.0.20 worked well. I can't upgrade to 8.0.21 because it was a bug with the stored procedure.

Exception: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Table 'sport_reservation.sport_reservation.tbl_dictionaries' doesn't exist

How to repeat:
Upgrade to 8.0.22.

Suggested fix:
Remove the replicated schema name.
[20 Oct 2020 9:10] MySQL Verification Team
Hello Matasci Sacha,

Thank you for the bug report.
Could you please provide the test case file to reproduce at our end?

Regards,
Ashwini Patil
[20 Oct 2020 11:12] Matasci Sacha
This is the code I've always used. Nothing is changed from the previous version.

// Initialize the connection string builder for the underlying provider.
var sqlBuilder = new MySqlConnectionStringBuilder
{
    Server = "servername",
    Database = "dbname",
    UserID = "user",
    Password = "password",
    PersistSecurityInfo = true,
    SslMode = MySqlSslMode.None 
};

// Initialize the EntityConnectionStringBuilder.
var entityBuilder = new EntityConnectionStringBuilder
{
    Provider = "MySql.Data.MySqlClient",
    ProviderConnectionString = sqlBuilder.ToString(),
    Metadata = @"res://*/LocalizationService.Database.DBModel.csdl|res://*/LocalizationService.Database.DBModel.ssdl|res://*/LocalizationService.Database.DBModel.msl"
};

_entityconnessione = new EntityConnection(entityBuilder.ToString());

This is the connection string generated...
metadata=res://*/Database.DBModel.csdl|res://*/Database.DBModel.ssdl|res://*/Database.DBModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=server;database=dbname;user id=user;password=password;port=3306;sslmode=None;persistsecurityinfo=True"

This is the exception
MySql.Data.MySqlClient.MySqlException: 'Table 'dbname.user.tbl_dizionario' doesn't exist'
[21 Oct 2020 5:55] Matasci Sacha
Hi, 
if you see my code below, there isn't any duplicated schema.
I didn't change my code, i've just upgraded to the 8.0.22 mysql library version.
[21 Oct 2020 5:57] Matasci Sacha
In the example.

sport_reservation.sport_reservation.tbl_dictionaries

the first sport_reservation is the schema
the second sport_reservation is the username
[30 Oct 2020 7:31] MySQL Verification Team
Bug #101384 marked as duplicate of this one.
[26 Nov 2020 5:39] zb c
I got same bug. Downgrade NuGet MySql.Data.EntityFramework from 8.0.22 to 8.0.21 can solve the bug.
[6 Jan 2021 5:43] MySQL Verification Team
Hello Matasci Sacha,

Thank you for the feedback.
The code given is not enough to reproduce the error. Could you please provide more information including stack trace of the exception.

Regards,
Ashwini Patil
[6 Jan 2021 9:54] zb c
I upload a project for reproducing, hope this helps.
https://github.com/zzbbcc/MySQL_Bug_101236

You can find more explanation and dump there.
[6 Jan 2021 15:27] Tom M.
I got the same bug when I upgraded to MySql.Data.EntityFramework 8.0.22. I had to rollback to the 8.0.21 version.

With the 8.0.22 version, I have this type of error :
"Table 'database2.database1.mytable' doesn't exist"
(the right path to the table is "database2.mytable")

I created my EF schema using "Database first", on the database "database1".
Throught the connection string of my project, I'm connected to a different database (same database schema, but different name), "database2".
[8 Jan 2021 5:44] MySQL Verification Team
Hello,

Thank you for the detailed project.
Discussed this issue internally with the Connector/NET developer and confirmed that C/NET 8.0.22 is affected. Thank you!

Regards,
Ashwini Patil
[22 Jan 2021 17:40] Matasci Sacha
Hi,

I saw you have updated the version to 8.0.23, but the problem still remain.
It is correct?

Thank you for your support.
[25 Jan 2021 23:26] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.0.24 release, and here's the proposed changelog entry from the documentation team:

A data table declared using valid database.table syntax within an Entity
Framework model could have extra database names in the generated query
(for example, database.database.table).

Thank you for the bug report.
[18 Feb 2021 13:12] MySQL Verification Team
Bug #102576 marked as duplicate of this one.
[24 Apr 2021 17:48] Rob Janssen
Updated to 8.0.24
Getting data from database works.
But when saving data I still get the error:
Table database.database.table does not exists.
I'm using a UnitOfWork with a Commit
[26 Apr 2021 9:55] Tom M.
With the 8.0.24 version, reading data from the database is still KO for me.
It keeps trying accessing to that kind of path : database1.database2.mytable
[13 May 2021 16:25] Pablo Mazza
This is not resolved in 8.0.24.
[13 May 2021 16:25] Pablo Mazza
This is not resolved in 8.0.24.
[18 May 2021 10:25] Krish KM
Bug still exists in 8.0.25!
[20 May 2021 22:56] Daniel Valdez
Can you please help us and attach a test project so we could reproduce the
exact same issue? It would be very helpful to us.
[20 May 2021 23:43] Pablo Mazza
Hi Daniel,

Considering this issue appears in a Database First Entity Framework model, it is difficult to provide a sample project without access to a database server.

If you can provide me with credentials to any sample Mysql database I can reproduce the issue for you and send you a sample project.

In any case, the problem lies in the following section of the EMDX file

<edmx:StorageModels>
      <Schema Namespace="RfamModel.Store" Provider="MySql.Data.MySqlClient" ProviderManifestToken="5.6" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
        <EntityType Name="author">
          <Key>
            <PropertyRef Name="author_id" />
          </Key>
          <Property Name="author_id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
          <Property Name="name" Type="varchar" MaxLength="20" Nullable="false" />
          <Property Name="last_name" Type="varchar" MaxLength="50" />
          <Property Name="initials" Type="varchar" MaxLength="4" />
          <Property Name="orcid" Type="varchar" MaxLength="19" />
          <Property Name="synonyms" Type="varchar" MaxLength="100" />
        </EntityType>
        <EntityContainer Name="RfamModelStoreContainer">
          <EntitySet Name="author" EntityType="Self.author" Schema="Rfam" store:Type="Tables" />
        </EntityContainer>
      </Schema>
    </edmx:StorageModels>

---------------------

More specifically here:

<EntityContainer Name="RfamModelStoreContainer">
          <EntitySet Name="author" EntityType="Self.author" Schema="Rfam" store:Type="Tables" />
</EntityContainer>

The tool automatically adds Schema="Rfam" which is the name of the database. If you keep it that way, you can't write to the database and get the error as if you were trying to write to Rfam.author table in the Rfam schema.

If you replace that entry with Schema="" it works, but at the expense of the designer tool no longer recognizing the already mapped tabled and making a mess when updating the model.

The solution I have so far is to remove the schema name when deploying the application and adding it back when designing. Not ideal.

Thanks for your help.
[26 May 2021 2:48] yingxia zhao
same error still exists in 8.0.25
[26 May 2021 19:00] Daniel Valdez
This will be re-fixed and included in 8.0.26 release
[31 May 2021 12:38] MySQL Verification Team
Bug #103411 marked as duplicate of this one.
[29 Jul 2021 18:18] Matasci Sacha
Hi,
I've upgraded to 8.0.26 but the problem still remain.

Thank you for your support.

---
I've reopened the ticket.
[18 Sep 2021 11:47] Dean Turnbull
This issue still exists, under 8.0.26 generating an edmx results in a query statement containing <dbname>.<dbname>.<viewname>

VS2016
MySQL for VS 1.2.10
Connector/Net 8.0.26
NuGet MySql 8.0.26

Fix in regards to changing the value in the EDMX XML under store:Schema="<dbname>" to store:Schema="" works
[29 Sep 2021 5:35] Kai Neumann
Why is this bug still closed although the problem still exists ?
[1 Oct 2021 20:45] Pablo Mazza
Will this ever be resolved? It is really a pain and was supposed to be fixed some versions ago.

Anybody from the dev team sees this?
[2 Oct 2021 15:33] Carlos Ayala
I following this bug some time ago, no answers, no nothing. I won't expect this to be fixed soon, so take a look to other ways of solving it
[4 Oct 2021 14:00] Daniel Valdez
Posted by developer:
 
Just wanted to let you know that we are aware of this issue and the importance of it. We are working on the fix. Please follow bug https://bugs.mysql.com/bug.php?id=104540
[30 Mar 2023 11:04] Kai Neumann
Hi,

the bug still exists (or exists again?) on version 8.0.32.1....
So we still have to remain on 8.0.21 

In our case, the problem occurs in the Database First environment.

And: It seems that #101236 is not a copy of #104540:

#104540: Table 'dbname.user.table' does not exist.
(additional user name between schema and table name)

#101236 : table 'sport_reservation.sport_reservation.tbl_dictionaries' does not exist
(double naming of the schema before the table name)

The problem that is currently still open concerns the double naming of the schema in a Database First environment
[15 Apr 2023 5:27] Pablo Mazza
This should be reopened. It is not working again in 8.0.32.1. Same behavior with the duplicate table in the edmx file.