Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pomelo Entity Framework connector is not able to recreate database. #7890

Closed
awarycha opened this issue May 23, 2024 · 6 comments
Closed

Pomelo Entity Framework connector is not able to recreate database. #7890

awarycha opened this issue May 23, 2024 · 6 comments
Labels
correctness We don't return the same result as MySQL customer issue integrations Issues with tools connecting to/querying Dolt

Comments

@awarycha
Copy link

I have an ASP.NET application with Dolt in Docker dolthub/dolt-sql-server:1.34.0.
At the beginning I used MySql.EntityFrameworkCore in version 8.0.2 and it worked fine with recreation database structure
with EnsureCreated() method. But I decided to change it to Pomelo package because it has some troubles with merging and conflict resolving in transaction.
So currently I use Pomelo.EntityFrameworkCore.MySql package in version 8.0.2 and it works fine with transaction and merging but appears that there is some problem with database structure recreation.
I get errors:

unhandled exception of type 'MySqlConnector.MySqlException' occurred in Pomelo.EntityFrameworkCore.MySql.dll: 'database not found: mydb'

My dolt is recognized by autodetector as: 8.0.33-mysql

As a workaround currently I use both connectors one MySql.EntityFrameworkCore for database recreation and Pomelo for other operations but I would prefer to use only one of them.

Could you verify that this problem exist also on your side?

@timsehn
Copy link
Sponsor Contributor

timsehn commented May 23, 2024

Do you have a simpler repro? We're not super familiar with these connector. Even the code snippet that's executing when you get the error would help.

@timsehn timsehn added integrations Issues with tools connecting to/querying Dolt correctness We don't return the same result as MySQL labels May 23, 2024
@timsehn
Copy link
Sponsor Contributor

timsehn commented May 23, 2024

@fulghum is going to poke around for a bit and see if he can repro. He's our .NET specialist.

@fulghum
Copy link
Contributor

fulghum commented May 23, 2024

Hi @awarycha, awesome to see more .NET developers using Dolt! 🙌 Thank you for taking the time to open a GitHub issue and report this problem. We appreciate hearing feedback about the .NET developer experience with Dolt.

We have a small ASP.NET Core sample app using Dolt that I was able to repro this with. You can find the repo on GitHub and there's also a DoltHub blog post explaining it it in more detail.

I added this code to the Program.cs to call EnsureCreated():

var scope = app.Services.CreateScope();
var context = scope.ServiceProvider.GetRequiredService<DoltContext>();
context.Database.EnsureCreated();

When the database exists, but the schema needs to be created, this seems to work correctly. When the database does not exist at all, I get the error: Unhandled exception. MySqlConnector.MySqlException (0x80004005): database not found: dolt/main

From looking at the Pomelo code, I believe this is happening because it doesn't recognize the error code Dolt is sending back when Pomelo checks for database existence. I'm going to try a quick experiment to change that error code to what Pomelo is expecting (error code 1049) and see if that makes the error go away.

Thanks for reporting this issue. 🙏 I'll keep you updated with what I find next.

@fulghum
Copy link
Contributor

fulghum commented May 23, 2024

I can confirm that returning error code 1049 for the "database not found" error now allows my repro to correctly create the database and schema using EnsureCreated().

I'm going to clean up my change, add some tests, and get it out for review.

fulghum added a commit to dolthub/go-mysql-server that referenced this issue May 23, 2024
…ping errors from ComInitDB to MySQL errors with error codes.

dolthub/dolt#7890
@fulghum
Copy link
Contributor

fulghum commented May 23, 2024

@awarycha – We've just released Dolt 1.38.3, which contains the fix for this issue.

Thank you for taking the time to try out Dolt and report this issue so we could fix it! 🙏 Please let us know if you hit any other snags or have any feedback for us on how we can improve the .NET Dolt experience.

@awarycha
Copy link
Author

awarycha commented May 24, 2024

Great, very fast response. Good job. I can confirm that recreation started working on dolt 1.38.3 and 1.39.0. But I noticed another problem with Pomelo and these versions of Dolt. Pomelo is not able to successfully commit changes. It worked for Dolt dolthub/dolt-sql-server:1.34.0. So it is some kind of regress. I've created new issue for that. #7897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
correctness We don't return the same result as MySQL customer issue integrations Issues with tools connecting to/querying Dolt
Projects
None yet
Development

No branches or pull requests

4 participants