Merge pull request #784 from tgstation/EVERY-FUCKING-TIME

Please delete named pipes
This commit is contained in:
Jordan Brown
2018-10-14 15:21:59 -04:00
committed by GitHub
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ Create an `appsettings.Production.json` file next to `appsettings.json`. This wi
- `Database:MySqlServerVersion`: The version of MySql/MariaDB the database resides on, can be left as null for attempted auto detection. Used by the MySQL/MariaDB provider for selection of [certain features](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/2.1.1/src/EFCore.MySql/Storage/Internal/ServerVersion.cs) ignore at your own risk. A string in the form `<major>.<minor>.<patch>`
- `Database:ConnectionString`: Connection string for your database. Click [here](https://www.developerfusion.com/tools/sql-connection-string/) for an SQL Server generator or see [here](https://www.connectionstrings.com/mysql/) for a MySQL guide.
- `Database:ConnectionString`: Connection string for your database. Click [here](https://www.developerfusion.com/tools/sql-connection-string/) for an SQL Server generator or see [here](https://www.connectionstrings.com/mysql/) for a MySQL guide ([You should probably use '127.0.0.1' instead of 'localhost'](https://stackoverflow.com/questions/19712307/mysql-localhost-127-0-0-1)).
### Database Configuration
@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
using System;
using Tgstation.Server.Host.Configuration;
@@ -26,6 +27,12 @@ namespace Tgstation.Server.Host.Models
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
base.OnConfiguring(options);
var stringDeconstructor = new MySqlConnectionStringBuilder
{
ConnectionString = DatabaseConfiguration.ConnectionString
};
if (stringDeconstructor.Server == "localhost")
Logger.LogWarning("MariaDB/MySQL server address is set to 'localhost'! If there are connection issues, try setting it to '127.0.0.1'!");
if (!String.IsNullOrEmpty(DatabaseConfiguration.MySqlServerVersion))
options.UseMySql(DatabaseConfiguration.ConnectionString, mySqlOptions => mySqlOptions.ServerVersion(Version.Parse(DatabaseConfiguration.MySqlServerVersion), DatabaseConfiguration.DatabaseType == DatabaseType.MariaDB ? ServerType.MariaDb : ServerType.MySql));
else