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
ServerVersion.AutoDetect(connectionString) fails #1859
Comments
@pantonis What version of Pomelo where you using before the upgrade?
Pomelo.EntityFrameworkCore.MySql/src/EFCore.MySql/Infrastructure/ServerVersion.cs Lines 61 to 82 in c8bf3ea
To generate the appropriate migrations, Pomelo needs to know the correct server version. We generally do not recommend using var optionsBuilder = new DbContextOptionsBuilder<MyDbContext>()
.UseMySql(
connectionString,
ServerVersion.Parse("10.10.1-mariadb"),
options =>
{
options.EnableRetryOnFailure();
options.MigrationsAssembly("MyAssembly.MariaDb");
}); |
We updated 8.X but we didn't use migrations on 8.0.0. We used migrations on 7.X and then on 8.0.1 where we hit the issue We have several clients each running different version of MariaDb. If we configure it somehow on each client then on each client update of MariaDb we need to update all of it microservices. This is very inconvienent as we have a lot of clients and dozens of microservices that need to be updated. Any other workaround |
Pomelo needs to know the version of the database server (or at least the minimum server version it should support). If you want to use If you are having multiple clients with different database server versions, they are also using different connection strings. If you want to use the latest features for all your clients, you should generate an individual migration set for each client using their individual database server version. If you don't care about the latest MariaDB features for all you clients, you could specify a static minimum server version that is <= the lowest server version of any of your clients. Then you can generate one set of migrations that works for all your clients. |
It is reachable. That is why I opened the ticket. Because with 7.0 version we didn't have any issues on that. |
If I understand you correctly, you said earlier that you did not use migrations before
Did I understand you correctly, or did you use migrations before |
Apologies for confusing you. We didn't use it for 8.0.0. We used it for version 7.X and then we upgraded to 8.0.1 and tried to use it on 8.0.1. This is where we noticed the issue. Let me correct my initial message |
Please check, that you can indeed connect to the database from the same machine, that you execute the Execute the following in a new console program on the same machine, that you execute the var connectionString = "your connection string 100% identical to the one you use in your app";
using var connection = new MySqlConnection(connectionString);
connection.Open(); If it works, then move to the next section below. There was a single change between Those changes should not have any influence on the matter, but if you want to verify this, you could revert those changes in a customized auto detect method: public static ServerVersion CustomAutoDetect(string connectionString)
{
using var connection = new MySqlConnection(
new MySqlConnectionStringBuilder(connectionString)
{
Database = string.Empty,
// AutoEnlist = false,
// Pooling = false,
}.ConnectionString);
connection.Open();
return Parse(connection.ServerVersion);
} You then call this If it suddenly works, than |
@pantonis Did you try the steps I outlined in my previous post? |
Steps to reproduce
Ideally include a complete code listing that we can run to reproduce the issue.
Alternatively, you can provide a project/solution that we can run.
The issue
I am trying to run Add-Migration command and I get
Further technical details
This is my code
As soon as I change it to this
It works. I have just updated to 8.0.1 so I don't know if this is the cause
MySQL version: 10.10.1 (MariaDb)
Operating system: Windows 10
Pomelo.EntityFrameworkCore.MySql version: 8.0.1
Microsoft.AspNetCore.App version: 8.0.2
Other details about my project setup:
The text was updated successfully, but these errors were encountered: