Add MySQL Provider
geekz-reno opened this issue · 1 comments
Hi, thank for your great efforts for this boilerplate.
Just want to add some instruction for newcomers like me, if you prefer to use mysql than mssql,
-
delete all existing file inside migrations folder on both project
- {YourProjectName}.Infrastructure.Identity
- {YourProjectName}.Infrastructure.Persistence
-
change from
options.UseSqlServer
tooptions.UseMySql
inServiceExtensions.cs
andServiceRegistration.cs
-
run
dotnet add package Pomelo.EntityFrameworkCore.MySql --version 3.1.2
on two project/subproject -
on
IdentityContext.cs
commentbuilder.HasDefaultSchema("Identity");
because ef doesn't support that on mysql -
cd to
{YourProjectName}.Infrastructure.Identity
and rundotnet ef database update --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "IdentityContext"
dotnet ef migrations add Initial --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "IdentityContext"
-
cd to
{YourProjectName}.Infrastructure.Persistence
and rundotnet ef database update --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "ApplicationDbContext"
dotnet ef migrations add Initial --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "ApplicationDbContext"
One more, when i try to login i got this error,
{ "Succeeded": false, "Message": "nodename nor servname provided, or not known", "Errors": null, "Data": null }
the problem was with var host = Dns.GetHostEntry(Dns.GetHostName());
in IpHelper.cs
just try to replace with,
private static string GetLocalIPv4(NetworkInterfaceType type)
{
var output = "";
foreach (var item in NetworkInterface.GetAllNetworkInterfaces())
{
if (item.NetworkInterfaceType == type && item.OperationalStatus == OperationalStatus.Up)
{
var adapterProperties = item.GetIPProperties();
if (adapterProperties.GatewayAddresses.FirstOrDefault() != null)
{
foreach (var ip in adapterProperties.UnicastAddresses)
{
if (ip.Address.AddressFamily != AddressFamily.InterNetwork) continue;
output = ip.Address.ToString();
break;
}
}
}
if (output != "")
break;
}
return output;
}
public static string GetIpAddress()
{
return GetLocalIPv4(NetworkInterfaceType.Ethernet);
// var host = Dns.GetHostEntry(Dns.GetHostName());
// foreach (var ip in host.AddressList)
// {
// if (ip.AddressFamily == AddressFamily.InterNetwork)
// {
// return ip.ToString();
// }
// }
// return string.Empty;
}
reff this
Thanks! i was wanting to write the steps for MySQL migration for quite a while now. Thanks for getting done with it :D
I have not got the issue with the IP function. I will give it a check.