测试兼容mysql

This commit is contained in:
falcon 2020-04-23 10:05:05 +08:00
parent d4ed14d313
commit b9cef41cc2
2 changed files with 13 additions and 11 deletions

View File

@ -7,6 +7,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Falcon.Extend" Version="1.2.1" /> <PackageReference Include="Falcon.Extend" Version="1.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.1.3" /> <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.3" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.3" />

View File

@ -40,17 +40,18 @@ namespace FAuth
//注册数据库 //注册数据库
services.AddDbContext<FAuthDb>(option => { services.AddDbContext<FAuthDb>(option => {
//option.UseSqlServer(this.Configuration.GetValue<string>("Database:FAuthDbSqlServer")); //option.UseSqlServer(this.Configuration.GetValue<string>("Database:FAuthDbSqlServer"));
var dbType = this.Configuration.GetValue<string>("Database:UseDb").ToLower(); option.UseMySQL(this.Configuration.GetValue<string>("Database:FAuthDbMySql"));
switch(dbType) { //var dbType = this.Configuration.GetValue<string>("Database:UseDb").ToLower();
case "mysql": //switch(dbType) {
option.UseMySQL(this.Configuration.GetValue<string>("Database:FAuthDbMySql")); // case "mysql":
break; // option.UseMySQL(this.Configuration.GetValue<string>("Database:FAuthDbMySql"));
case "sqlserver": // break;
option.UseSqlServer(this.Configuration.GetValue<string>("Database:FAuthDbSqlServer")); // case "sqlserver":
break; // option.UseSqlServer(this.Configuration.GetValue<string>("Database:FAuthDbSqlServer"));
default: // break;
throw new Exception("Database:UseDbÅäÖôíÎó£¡Ö»ÄÜΪmysql»òsqlserver"); // default:
} // throw new Exception("Database:UseDbÅäÖôíÎó£¡Ö»ÄÜΪmysql»òsqlserver");
//}
}); });
services.AddAccountHelper(); services.AddAccountHelper();
//注册Redis //注册Redis