'asp.net 6 EF using MySql Database not working

I am trying to connect my Web API build in asp.net 6 with MySql and I am having a lot of trouble

My Service looks like this

builder.Services.AddDbContext<TicketApiContext>(options =>
    options.UseMySQL("CONNECTION_STRING"));

and my Database Context like this.

using Microsoft.EntityFrameworkCore;
namespace VelocityNetAPI.Data
{
    public class TicketApiContext : DbContext
    {
        public TicketApiContext(DbContextOptions<TicketApiContext> options)
            : base(options)
        {
        }
        public DbSet<VelocityNetAPI.Models.Client> Client { get; set; }

        public DbSet<VelocityNetAPI.Models.Job> Job { get; set; }

        public DbSet<VelocityNetAPI.Models.User> User { get; set; }

        public DbSet<VelocityNetAPI.Models.Dev> Dev { get; set; }

        public DbSet<VelocityNetAPI.Models.FinishedJobs> FinishedJobs { get; set; }
        

    }
}

when I run add-migration initial I get an error

Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.TypeMappingSourceDependencies' while attempting to activate 'MySql.EntityFrameworkCore.Storage.Internal.MySQLTypeMappingSource'.

Any help will be very much appreciated.Here is my Nuget packages

Please help I am completely lost

Cheers All



Solution 1:[1]

So after tweaking I have the solution. Using the pomelo package and this line.

builder.Services.AddDbContext<TicketAPIContext>(options =>
  options.UseMySql(builder.Configuration.GetConnectionString("TicketApiContextMySql"), new MySqlServerVersion(new Version(8, 0, 22))));

Hope this helps devs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Riley-Howley