How to enable migration for EF 6.4 and MySQL C#?

c# ef-migrations entity-framework-6 migration mysql

Question

I tried to enable migrations using the command

Enable-Migrations

But I got the error below, I didn't really understand how to solve it...

I installed all the extensions to make it works. enter image description here

The error message :

Checking if the context targets an existing database...
No MigrationSqlGenerator found for provider 'MySql.Data.MySqlClient'. Use the SetSqlGenerator method in the target migrations configuration class to register additional SQL generators.
1
0
3/21/2020 3:32:04 PM

Popular Answer

I assume your project is a .net core application and you are using visual studio.

  1. Make sure you have Microsoft.Entityframeworkcore.tools install from Nuget Package Manager.
  2. From your package manager console, you don't need to enable migration as done previously in ef 5
  3. Just run Add-Migration {MigrationName}
  4. Run Update-Database to update the database

OR

  1. if the AppDbContext is in the same project with the startup file
  2. Run dotnet ef migrations add {MigrationName}
  3. Run dotnet ef -database update to update the database

OR

  1. if the AppDbContext is in the different project, Open the containing project root directory from the command line
  2. Run dotnet ef migrations add {MigrationName} --s ../{startupproject}/{startupproject.csproj}
  3. Run dotnet ef -database update to update the database --s ../{startupproject}/{startupproject.csproj}
0
3/21/2020 4:22:03 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow