3

I am building a project from startup template .Net Core v3.x and Angular. The project works fine with MSSQL server. I am trying to use MySql v8.0.27 instead, but when I run the Migrator I get the following error:

MySql.Data.MySqlClient.MySqlException (0x80004005): Unknown data type: 'datetime2'

I am using the following packages

  • Microsoft.EntityFrameworkCore 3.1.21
  • Microsoft.EntityFrameworkCore.Design 3.1.21
  • Microsoft.EntityFrameworkCore.Tools 3.1.21
  • Pomelo.EntityFrameworkCore.MySql 3.2.7
  • MySqlConnector 0.69.10

My DBContextConfigurer class is

    {
        public static void Configure(DbContextOptionsBuilder<LandAndBnbDbContext> builder, string connectionString)
        {
            builder.UseMySql(connectionString);
        }

        public static void Configure(DbContextOptionsBuilder<LandAndBnbDbContext> builder, DbConnection connection)
        {
            builder.UseMySql(connection);
        }
    }

and my appsettings.json file is

{
  "ConnectionStrings": {
    "Default": "Server=localhost; port=3307; Database=xxx; user=xxx; password=xxx"
  }
}

any ideas?

1 Answers1

2

Finally I managed to understand what is going and how to fix it...

For every database provider I should create a different set of Migrations, specific to every provider...

Solution from https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/865#issuecomment-780138527