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

Microsoft.EntityFrameworkCore.Database.Command Failed executing DbCommand (rename) #1116

Closed
rafaeldoria opened this issue Jul 6, 2020 · 4 comments

Comments

@rafaeldoria
Copy link

Steps to reproduce

when creating a migration to rename a column you get an exception

The issue

The command to rename the column is not that of mysql

migrationBuilder.RenameColumn(
name: "Name",
table: "User",
newName: "Username");

Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (5ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      ALTER TABLE `User` RENAME COLUMN `Name` TO `Username`;
Failed executing DbCommand (5ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
ALTER TABLE `User` RENAME COLUMN `Name` TO `Username`;

Further technical details

MySQL version: 5.7.30-log MySQL Community Server
Operating system: Windows 10 Pro
Pomelo.EntityFrameworkCore.MySql version: 3.1.1
Microsoft.AspNetCore.App version: 3.1

Other details about my project setup:
All other migrations went smoothly, including AlterColumn and AddColumn

@mguinness
Copy link
Collaborator

Have you set ServerVersion? In your case ServerVersion(new Version(5, 7, 30), ServerType.MySql)

@rafaeldoria
Copy link
Author

Check mysql config
image

@crozone
Copy link
Contributor

crozone commented Jul 7, 2020

Your Startup.cs requires ServerVersion(new Version(5, 7, 30), ServerType.MySql) so that Pomelo knows which dialect of MySql to use.

For example:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<ApplicationDbContext>(options =>
                options.UseMySql(connectionString,
                    o => o.ServerVersion(new Version(5, 7, 30), ServerType.MySql)
    );

    // ...
}

Does the issue persist after adding this?

@rafaeldoria
Copy link
Author

great!
it worked, thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants