Pomelo.entityframeworkcore.mysql: How to rename column in MariaDB

Created on 27 Nov 2019  路  2Comments  路  Source: PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

I have .Net Core Web API with MariaDB server. After update Pomelo and EF Core from 2 version to 3 exception is thrown while trying to apply migration with rename column logic.

Migration :

    public partial class EmployeeTimeCardChanges : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "EmpolyeeName",
                table: "EmployeeTimeCards",
                newName: "JobTitleName");
            ...

EF Core logs:

info: Microsoft.EntityFrameworkCore.Migrations[20402]
      Applying migration '20190516061945_EmployeeTimeCardChanges'.
info: Microsoft.EntityFrameworkCore.Database.Command[20100]
      Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
      ALTER TABLE `EmployeeTimeCards` RENAME COLUMN `EmpolyeeName` TO `JobTitleName`;
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (111ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      ALTER TABLE `EmployeeTimeCards` RENAME COLUMN `EmpolyeeName` TO `JobTitleName`;

As far as I know MariaDb is not supporting such syntax yet.

Technical details

MariaDB version: 10.4.6
Operating system: Windows 10 Pro x64
Pomelo.EntityFrameworkCore.MySql version: 3.0.0
Microsoft.AspNetCore.App version: 3.0.0

closed-question type-question

Most helpful comment

Are you specifying ServerVersion in configuration options when you set up your context?

c# options.UseMySql(myConnectionString, builder => builder.ServerVersion(new ServerVersion(new Version(10, 4, 6), ServerType.MariaDb)));

If no ServerVersion is configured, it is assumed you are using the latest Version of MySQL.

All 2 comments

Are you specifying ServerVersion in configuration options when you set up your context?

c# options.UseMySql(myConnectionString, builder => builder.ServerVersion(new ServerVersion(new Version(10, 4, 6), ServerType.MariaDb)));

If no ServerVersion is configured, it is assumed you are using the latest Version of MySQL.

Thanks, it works now. I've added ServerVersion in configuration.

Was this page helpful?
0 / 5 - 0 ratings