Menu
Cutty
  • Chryslers
  • Lutherie
  • YLSNED
  • About
Cutty

Entity Framework Migrations and Case Sensitivity in MariaDb

Posted on August 20, 2024 by Iain 'Cutty' Carlin

I did a ‘database first’ reverse engineering of an existing database to create a model for Entity Framework.

I then tried to use that model to create a migration and subsequent new database on a MariaDB instance running under Windows.

I kept getting an error message “Table ‘__efmigrationshistory’ already exists” whenever I ran “dotnet ef database update”. I suspected the issue was to do with case sensitivity of the table name(s).

Things I tried to resolve the issue:

  • Manually rename the table in the database to lower case.
  • Change the lower_case_table_names setting to 2 in my.ini (location is set in the windows service settings. Service must be restarted to take effect)
  • Change the table name in the Context.cs file

None of which worked.

Turned out the error was because I had scaffolded the database from the existing database which already had the EFMigrationsHistory table in it, so Entity Framework created a class in the scaffolded model for that table.

I deleted that entity, removed the migration and deleted the database. Then recreated the migration and updated the database and all was fine.

Recent Posts

  • 2024 was the best year for our solar system
  • Books I read in 2024
  • Books I read in 2023
  • Happy New Year 2024
  • Lawson – A life in words and music

Categories

  • Chryslers (1)
  • Cutty's Blog (12)
  • Lutherie (38)
  • You Learn Something New Every Day (43)
©2025 Cutty | Powered by Superb Themes