I want to switch from using SQL Server to MySql. I have already created migrations for SQL Server and have applied them to the DB. I have added the Pomelo Mysql package and now want to create migrations for a MySql db. My problem is that I am receiving an error in the Package Manager Console when trying to use the add-migration command.
- It's a.Net Core 2.2 project
- Pomelo.EntityFrameworkCore.MySql 2.2.0 has been added to the project
Startup / ConfigureServices
services.AddDbContext<ApplicationDbContext>(options => options.UseMySql(Configuration.GetConnectionString("DefaultConnection"),
mySqlOptions => { mySqlOptions.ServerVersion(new Version(8, 0, 16), ServerType.MySql); }));
csproj
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
</ItemGroup>
ApplicationDbContext Class
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql("Server=localhost;Database=myDbUid=myUserId;");
}
I am receiving the following error when trying to add a migration. "An item with the same key has already been added. Key: Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal.MySqlOptionsExtension" Does this error have anything to do with the fact I have previous migrations for MS SQL Server? Any help would be much appreciated.