I remodeld this question to fit another two tests upon the initial question.
What i did is i used this tutorials: https://www.youtube.com/watch?v=qTnT069Owkc and https://www.jerriepelser.com/blog/using-mariadb-with-aspnet-core They have a fairly simple aproach to connect a .net core app to mysql db (in my case its a mariadb) I have set up a user and granted all. I can connect with seqelpro (any db connection tool) and over CLI with that user and with root as well.
when i do migrations both of the applications it prints:
Mac:Company novski$ dotnet ef migrations add CreateIdentityModels
Done. To undo this action, use 'ef migrations remove'
Mac:Company novski$ dotnet ef database update
An error occurred using the connection to database '' on server 'localhost'.
MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
So it seams as if the program is not seeing the database name i have set in the line:
of the Youtube version:
using System;
using Microsoft.EntityFrameworkCore;
namespace Company.Data
{
public class ApplicationDbContext:DbContext
{
public DbSet<Employee> Employees { get; set; }
public DbSet<Department> Departments { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseMySql(
@"Server=localhost;database=company;uid=root;pwd=password;"
);
}
}
and Jerrie Pelser:
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;User=root;Password=password;Database=mariadbtest;"
},
howcome both applications exit with the same error? What am i missing?
User contributions licensed under CC BY-SA 3.0