when creating a migration to rename a column you get an exception
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`;
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
Have you set ServerVersion? In your case ServerVersion(new Version(5, 7, 30), ServerType.MySql)
Check mysql config
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?
great!
it worked, thanks!!!
Most helpful comment
Your
Startup.cs
requiresServerVersion(new Version(5, 7, 30), ServerType.MySql)
so that Pomelo knows which dialect of MySql to use.For example:
Does the issue persist after adding this?