Entity Framework MySql.Data.MySqlClient.MySqlException (0x80004005): Table already exists

0

I have been facing an issue while running EF command Update-Database in Package Manager Console. Below is the error I received please help me to resolve it.

MySql.Data.MySqlClient.MySqlException (0x80004005): Table 'tablename' already exists

asp.net-core
entity-framework-core
ef-code-first
asked on Stack Overflow Dec 18, 2020 by RAM G

1 Answer

0

By removing your previous migration that creates the table 'Student' EntityFramework now is generating the migration with a Create Table Script, if you want to remove a migration you must revert it from your database aswell. Now you can either recreate your database or revert/delete the 'Students' table on your database.

try to Run the

Add-Migration InitialCreate –IgnoreChanges 

command in Package Manager Console. This creates an empty migration with the current model as a snapshot. and then Run the

Update-Database

User contributions licensed under CC BY-SA 3.0