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.
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.
as the error message says, you need to change first the MigrationSqlGenerator. https://learn.microsoft.com/en-us/ef/ef6/fundamentals/configuring/code-based
you can do it in 2 ways:
modify the entityFramework section in your App.Config
<entityFramework codeConfigurationType="MyNamespace.MyDbConfiguration, MyAssembly">
...Your EF config...
</entityFramework>
OR add the DbConfigurationType attribute to your DbContext inherited class
[DbConfigurationType("MyNamespace.MyDbConfiguration, MyAssembly")]
public class MyContextContext : DbContext
{
}
for MySql.Data.Entity -> MySql.Data (>= 6.10.9)
<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
...other providers
</providers>
</entityFramework>
//
[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6))]
public class DemoContext : DbContext
{
}
for MySql.Data.EntityFramework -> MySql.Data (>= 8.0.20)
<entityFramework codeConfigurationType="MySql.Data.EntityFramework.MySqlEFConfiguration, MySql.Data.EntityFramework">
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.20.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
...other providers
</providers>
</entityFramework>
//
[DbConfigurationType(typeof(MySql.Data.EntityFramework.MySqlEFConfiguration, MySql.Data.EntityFramework))]
public class DemoContext : DbContext
{
}