更新工程:Bootstrap.Admin增加Postgresql支持
This commit is contained in:
parent
384be45a5b
commit
d209d30f05
|
@ -20,6 +20,13 @@
|
||||||
{
|
{
|
||||||
"Enabled": true
|
"Enabled": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Enabled": true,
|
||||||
|
"ProviderName": "Sqlite",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"ba": "Data Source=BootstrapAdmin.db;"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"ProviderName": "MySql",
|
"ProviderName": "MySql",
|
||||||
|
@ -29,9 +36,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"ProviderName": "Sqlite",
|
"ProviderName": "Npgsql",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"ba": "Data Source=BootstrapAdmin.db;"
|
"ba": "Server=localhost;Database=BootstrapAdmin;User ID=argozhang;Password=argo@163.com;"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//#define SQLite
|
//#define SQLite
|
||||||
//#define MySQL
|
//#define MySQL
|
||||||
|
//#define Npgsql
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System;
|
using System;
|
||||||
|
@ -57,28 +58,38 @@ namespace UnitTest
|
||||||
if (!File.Exists(dbFile)) File.Copy(dbPath, dbFile);
|
if (!File.Exists(dbFile)) File.Copy(dbPath, dbFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string SqlConnectionStrings = "Data Source=.;Initial Catalog=UnitTest;User ID=sa;Password=sa";
|
private const string SqlConnectionString = "Data Source=.;Initial Catalog=UnitTest;User ID=sa;Password=sa";
|
||||||
private const string SQLiteConnectionStrings = "Data Source=UnitTest.db;";
|
private const string SQLiteConnectionString = "Data Source=UnitTest.db;";
|
||||||
private const string MySqlConnectionStrings = "Server=localhost;Database=UnitTest;Uid=argozhang;Pwd=argo@163.com;SslMode=none;";
|
private const string MySqlConnectionString = "Server=localhost;Database=UnitTest;Uid=argozhang;Pwd=argo@163.com;SslMode=none;";
|
||||||
|
private const string NpgSqlConnectionString = "Server=localhost;Database=UnitTest;User ID=argozhang;Password=sa;";
|
||||||
|
|
||||||
public static void ConfigureWebHost(IWebHostBuilder builder)
|
public static void ConfigureWebHost(IWebHostBuilder builder)
|
||||||
{
|
{
|
||||||
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
||||||
new KeyValuePair<string, string>("ConnectionStrings:ba", SqlConnectionStrings),
|
new KeyValuePair<string, string>("ConnectionStrings:ba", SqlConnectionString),
|
||||||
new KeyValuePair<string, string>("DB:0:Enabled", "true")
|
new KeyValuePair<string, string>("DB:0:Enabled", "true")
|
||||||
}));
|
}));
|
||||||
#if SQLite
|
#if SQLite
|
||||||
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
||||||
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
||||||
new KeyValuePair<string, string>("DB:1:Enabled", "false"),
|
new KeyValuePair<string, string>("DB:1:Enabled", "true"),
|
||||||
new KeyValuePair<string, string>("DB:2:ConnectionStrings:ba", SQLiteConnectionStrings)
|
new KeyValuePair<string, string>("DB:1:ConnectionStrings:ba", SQLiteConnectionString)
|
||||||
}));
|
}));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MySQL
|
#if MySQL
|
||||||
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
||||||
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
||||||
new KeyValuePair<string, string>("DB:1:ConnectionStrings:ba", MySqlConnectionStrings)
|
new KeyValuePair<string, string>("DB:2:Enabled", "true"),
|
||||||
|
new KeyValuePair<string, string>("DB:2:ConnectionStrings:ba", MySqlConnectionString)
|
||||||
|
}));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if Npgsql
|
||||||
|
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
||||||
|
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
||||||
|
new KeyValuePair<string, string>("DB:3:Enabled", "true"),
|
||||||
|
new KeyValuePair<string, string>("DB:3:ConnectionStrings:ba", NpgSqlConnectionString)
|
||||||
}));
|
}));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -86,16 +97,20 @@ namespace UnitTest
|
||||||
public static IConfiguration CreateConfiguraton()
|
public static IConfiguration CreateConfiguraton()
|
||||||
{
|
{
|
||||||
var config = new ConfigurationBuilder().AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
var config = new ConfigurationBuilder().AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
||||||
new KeyValuePair<string, string>("ConnectionStrings:ba", SqlConnectionStrings),
|
new KeyValuePair<string, string>("ConnectionStrings:ba", SqlConnectionString),
|
||||||
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
||||||
|
|
||||||
new KeyValuePair<string, string>("DB:1:Enabled", "false"),
|
new KeyValuePair<string, string>("DB:1:Enabled", "false"),
|
||||||
new KeyValuePair<string, string>("DB:1:ProviderName", "SQLite"),
|
new KeyValuePair<string, string>("DB:1:ProviderName", "SQLite"),
|
||||||
new KeyValuePair<string, string>("DB:1:ConnectionStrings:ba", SQLiteConnectionStrings),
|
new KeyValuePair<string, string>("DB:1:ConnectionStrings:ba", SQLiteConnectionString),
|
||||||
|
|
||||||
new KeyValuePair<string, string>("DB:2:Enabled", "false"),
|
new KeyValuePair<string, string>("DB:2:Enabled", "false"),
|
||||||
new KeyValuePair<string, string>("DB:2:ProviderName", "MySql"),
|
new KeyValuePair<string, string>("DB:2:ProviderName", "MySql"),
|
||||||
new KeyValuePair<string, string>("DB:2:ConnectionStrings:ba", MySqlConnectionStrings),
|
new KeyValuePair<string, string>("DB:2:ConnectionStrings:ba", MySqlConnectionString),
|
||||||
|
|
||||||
|
new KeyValuePair<string, string>("DB:3:Enabled", "false"),
|
||||||
|
new KeyValuePair<string, string>("DB:3:ProviderName", "NPgsql"),
|
||||||
|
new KeyValuePair<string, string>("DB:3:ConnectionStrings:ba", NpgSqlConnectionString),
|
||||||
new KeyValuePair<string, string>("LongbowCache:Enabled", "false")
|
new KeyValuePair<string, string>("LongbowCache:Enabled", "false")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -111,6 +126,12 @@ namespace UnitTest
|
||||||
new KeyValuePair<string, string>("DB:2:Enabled", "true")
|
new KeyValuePair<string, string>("DB:2:Enabled", "true")
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if Npgsql
|
||||||
|
config.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
||||||
|
new KeyValuePair<string, string>("DB:3:Enabled", "true")
|
||||||
|
});
|
||||||
|
#endif
|
||||||
return config.Build();
|
return config.Build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.1" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||||
<PackageReference Include="MySql.Data" Version="8.0.13" />
|
<PackageReference Include="MySql.Data" Version="8.0.13" />
|
||||||
|
<PackageReference Include="Npgsql" Version="4.0.4" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|
Loading…
Reference in New Issue