title: Conenection between Mysql and Visual Studio 2019 for macOS doesn't work
body: <p>I'm trying to develope a Web Application (.net core MVC)  with Visual Studio 2019 for macOS and as database I use Mysql.</p>
  
  <p>I've been looking for videos, websites where tell you how to make the connection, but all attempts have been failed.</p>
  
  <p>I'll show you my code:</p>
  
  <p>NuGet Packages:</p>
  
  <ul>
  <li>Microsoft.AspNetCore.App(2.1.1)</li>
  <li>Microsoft.AspNetCore.Identity.EntityFrameworkCore(2.1.1) </li>
  <li>Microsoft.AspNetCore.Razor.Design(2.1.2)</li>
  <li>Microsoft.EntityFrameworkCore.Tools(2.1.1)</li>
  <li>Mysql.Data</li>
  <li>Mysql.Data.EntityFrameworkCore(8.0.17)</li>
  </ul>
  
  <p>SDK:</p>
  
  <ul>
  <li>MicrosoftNETCore.App(2.1.0)</li>
  </ul>
  
  <pre><code>
      // Data Access Object -&gt; MysqlContext.cs :
  
      using System;
      using System.Linq;
      using System.Collections.Generic;
      using System.Threading.Tasks;
      using Microsoft.Extensions.DependencyInjection;
      using Microsoft.AspNetCore.Http;
      using Microsoft.Extensions.Configuration;
      using Microsoft.EntityFrameworkCore;
      using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
      using MySql.Data.MySqlClient;
      using VideoClubSharp.Models;
  
  
      namespace VideoClubSharp.DAO
      {
          public class MysqlContext : IdentityDbContext&lt;AplicationUser&gt;
          {
              public string ConnectionString { get; set; }
  
              public MysqlContext(DbContextOptions&lt;MysqlContext&gt; options) : base(options)
              {
                  this.Database.EnsureCreated();
              }
  
              protected override void OnModelCreating(ModelBuilder builder)
              {
                  base.OnModelCreating(builder);
              }
  
              private MySqlConnection GetConnection()
              {
                  return new MySqlConnection(ConnectionString);
              }
  
              public List&lt;ActorMO&gt; GetActorMOs()
              {
                  var Result = new List&lt;ActorMO&gt;();
  
                  using(MySqlConnection db = GetConnection())
                  {
                      db.Open();
                      MySqlCommand query = new MySqlCommand("select * from Actor", db);
                      using (MySqlDataReader row = query.ExecuteReader())
                      {
                          while (row.Read())
                          {
                              int idActor = row.GetInt32("idActor");
                              string FullName = row.GetString("FullName");
                              char Sex = row.GetChar("Sex");
                              Result.Add(new ActorMO(idActor, FullName, Sex));
                          }
                      }
                  }
  
                  return Result;
              }
          }
      }
  
      // Models -&gt; ActorMO &amp; AplicationUser;
  
      // ActorMO.cs:
  
      using System;
  
      namespace VideoClubSharp.Models
      {
          public class ActorMO 
          {
              public int idActor { get; set; }
              public string FullName { get; set; }
              public char Sex { get; set; }
  
              public ActorMO(int idActor, string FullName, char Sex) 
              {
                  this.idActor = idActor;
                  this.FullName = FullName;
                  this.Sex = Sex;
              }
          }
      }
  
  
      // AplicationUser.cs: 
  
      using System;
      using Microsoft.AspNetCore.Identity;
  
  
      namespace VideoClubSharp.Models
      {
          public class AplicationUser : IdentityUser
          {
              public AplicationUser()
              {
              }
          }
      }
  
      // appsettings.json
      {
        "Logging": {
          "IncludeScopes":  false,
          "LogLevel": {
            "Default": "Warning"
          }
        },
        "AllowedHosts": "*",
        "ConnectionString" :  {
          "MysqlConnection" :  "server@localhost; userid=root; password=****; port=3306: datanase=VideoClub; sslmode=none;"
        }
      }
  
      // Startup.cs
  
      namespace VideoClubSharp
      {
          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.Configure&lt;CookiePolicyOptions&gt;(options =&gt;
                  {
                      // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                      options.CheckConsentNeeded = context =&gt; true;
                      options.MinimumSameSitePolicy = SameSiteMode.None;
                  });
  
                  services.AddDbContext&lt;MysqlContext&gt;(options =&gt; options.UseMySQL(Configuration.GetConnectionString("MysqlConnection")));
                  services.AddIdentity&lt;AplicationUser, IdentityRole&gt;().AddEntityFrameworkStores&lt;MysqlContext&gt;().AddDefaultTokenProviders();
                  //services.Add(new ServiceDescriptor(typeof(mysqlContext), new mysqlContext(Configuration.GetConnectionString("MysqlConnection"))));
                  services.AddMvc();
                  services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
              }
  
              // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
              public void Configure(IApplicationBuilder app, IHostingEnvironment env)
              {
                  if (env.IsDevelopment())
                  {
                      app.UseDeveloperExceptionPage();
                  }
                  else
                  {
                      app.UseExceptionHandler("/Home/Error");
                      app.UseHsts();
                  }
  
                  app.UseHttpsRedirection();
                  app.UseStaticFiles();
                  app.UseCookiePolicy();
  
                  app.UseMvc(routes =&gt;
                  {
                      routes.MapRoute(
                          name: "default",
                          template: "{controller=Home}/{action=Index}/{id?}");
                  });
              }
          }
      }
  
      // ActorController.cs     
  
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Threading.Tasks;
      using Microsoft.AspNetCore.Mvc;
      using VideoClubSharp.DAO;
      using VideoClubSharp.Models;
  
      // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
  
      namespace VideoClubSharp.Controllers
      {
          public class ActorController : Controller
          {
              public IActionResult Index()
              {
                  MysqlContext Data = HttpContext.RequestServices.GetService(typeof(MysqlContext)) as MysqlContext;
                  return View(Data.GetActorMOs().ToList()) ;
              }
          }
      }
  
  
  
       //And I've put an ActionLink in Home page, to see the Actors from //Database, but show the next error:
  
  
      An unhandled exception occurred while processing the request.
  
      ArgumentNullException: Value cannot be null.
      Parameter name: connectionString
      Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(string value, string parameterName)
  
  
  
      ArgumentNullException: Value cannot be null. Parameter name: connectionString
      Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(string value, string parameterName)
      Microsoft.EntityFrameworkCore.Infrastructure.RelationalOptionsExtension.WithConnectionString(string connectionString)
      Microsoft.EntityFrameworkCore.MySQLDbContextOptionsExtensions.UseMySQL(DbContextOptionsBuilder optionsBuilder, string connectionString, Action&lt;MySQLDbContextOptionsBuilder&gt; MySQLOptionsAction)
      VideoClubSharp.Startup.&lt;ConfigureServices&gt;b__4_1(DbContextOptionsBuilder options) in Startup.cs
      +
                  services.AddDbContext&lt;MysqlContext&gt;(options =&gt; options.UseMySQL(Configuration.GetConnectionString("MysqlConnection")));
      Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions+&lt;&gt;c__DisplayClass1_0&lt;TContextService, TContextImplementation&gt;.&lt;AddDbContext&gt;b__0(IServiceProvider p, DbContextOptionsBuilder b)
      Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory&lt;TContext&gt;(IServiceProvider applicationServiceProvider, Action&lt;IServiceProvider, DbContextOptionsBuilder&gt; optionsAction)
      Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions+&lt;&gt;c__DisplayClass10_0&lt;TContextImplementation&gt;.&lt;AddCoreServices&gt;b__0(IServiceProvider p)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor&lt;TArgument, TResult&gt;.VisitCallSite(IServiceCallSite callSite, TArgument argument)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor&lt;TArgument, TResult&gt;.VisitCallSite(IServiceCallSite callSite, TArgument argument)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor&lt;TArgument, TResult&gt;.VisitCallSite(IServiceCallSite callSite, TArgument argument)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor&lt;TArgument, TResult&gt;.VisitCallSite(IServiceCallSite callSite, TArgument argument)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine+&lt;&gt;c__DisplayClass1_0.&lt;RealizeService&gt;b__0(ServiceProviderEngineScope scope)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
      Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
      VideoClubSharp.Controllers.ActorController.Index() in ActorController.cs
      +
                  MysqlContext Data = HttpContext.RequestServices.GetService(typeof(MysqlContext)) as MysqlContext;
      lambda_method(Closure , object , object[] )
      Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, object[] parameters)
      Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
      Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
      Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
      Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
      Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
      Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
      Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
      Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
      Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
      Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
      Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
      Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
      Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
      Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
  
  </code></pre>