CS1503 error: Argument 2: cannot convert from "string" to "Microsoft.EntityFrameworkCore.Serverversion"

Asked

Viewed 70 times

-1

Help me boys, I’ve tried everything and the mistake doesn’t come out at all!!!

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using projeto_POO_seige.Data;

namespace projeto_POO_seige
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddDbContext<SeigeProjetoContext>(options => 
            options.UseMySql(Configuration.GetConnectionString("SeigeProjetoContext"), 
            builder => builder.MigrationsAssembly("Projeto_POO_Seige")));

            services.AddMvc();
        }

1 answer

0

The error seems to be very clear, you are passing a string instead of an object of the Serverversion type. See the parameters that the Usemysql method waits for.

string connectionString = Configuration.GetConnectionString("SeigeProjetoContext");


x.UseMySql(connectionString , ServerVersion.AutoDetect(connectionString)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.