测试兼容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();
switch(dbType) {
case "mysql":
option.UseMySQL(this.Configuration.GetValue<string>("Database:FAuthDbMySql")); option.UseMySQL(this.Configuration.GetValue<string>("Database:FAuthDbMySql"));
break; //var dbType = this.Configuration.GetValue<string>("Database:UseDb").ToLower();
case "sqlserver": //switch(dbType) {
option.UseSqlServer(this.Configuration.GetValue<string>("Database:FAuthDbSqlServer")); // case "mysql":
break; // option.UseMySQL(this.Configuration.GetValue<string>("Database:FAuthDbMySql"));
default: // break;
throw new Exception("Database:UseDbÅäÖôíÎó£¡Ö»ÄÜΪmysql»òsqlserver"); // case "sqlserver":
} // option.UseSqlServer(this.Configuration.GetValue<string>("Database:FAuthDbSqlServer"));
// break;
// default:
// throw new Exception("Database:UseDbÅäÖôíÎó£¡Ö»ÄÜΪmysql»òsqlserver");
//}
}); });
services.AddAccountHelper(); services.AddAccountHelper();
//注册Redis //注册Redis