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