切换数据库位PostgreSQL 18.1版本
This commit is contained in:
parent
ea48f30d4f
commit
0db946724c
@ -34,11 +34,12 @@
|
||||
|
||||
<!--FreeSql-->
|
||||
<PackageReference Update="FreeSql.Cloud" Version="2.0.1" />
|
||||
<PackageReference Update="FreeSql.Extensions.JsonMap" Version="3.5.303" />
|
||||
<PackageReference Update="FreeSql" Version="3.5.303"/>
|
||||
<PackageReference Update="FreeSql.Provider.MysqlConnector" Version="3.5.303"/>
|
||||
<PackageReference Update="FreeSql.Provider.Sqlite" Version="3.5.303"/>
|
||||
<PackageReference Update="FreeSql.Provider.SqlServer" Version="3.5.303" />
|
||||
<PackageReference Update="FreeSql.Extensions.JsonMap" Version="3.5.305" />
|
||||
<PackageReference Update="FreeSql" Version="3.5.305"/>
|
||||
<PackageReference Update="FreeSql.Provider.MysqlConnector" Version="3.5.305"/>
|
||||
<PackageReference Update="FreeSql.Provider.Sqlite" Version="3.5.305"/>
|
||||
<PackageReference Update="FreeSql.Provider.SqlServer" Version="3.5.305" />
|
||||
<PackageReference Update="FreeSql.Provider.PostgreSQL " Version="3.5.305" />
|
||||
|
||||
<!-- 单元测试包-->
|
||||
<PackageReference Update="xunit" Version="2.9.3"/>
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
"CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.90.3:4200"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB386;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
||||
//"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB386;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
||||
"Default": "Host=192.168.111.174;Port=5432;Database=jisheiotprodb;Username=postgres;Password=JiShe!aqG#5kGgh&0;Encoding=UTF8;Pooling=true;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=100;"
|
||||
},
|
||||
"Hangfire": {
|
||||
"Redis": {
|
||||
|
||||
@ -4,6 +4,7 @@ using JiShe.ServicePro.Core;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.IoT.CommonServices
|
||||
@ -19,7 +20,45 @@ namespace JiShe.IoT.CommonServices
|
||||
public void InitSelectTypetList()
|
||||
{
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
var typeList = assemblies.SelectMany(x => x.GetTypes()).Where(x => x.IsDefined(typeof(SelectResultAttribute), false));
|
||||
|
||||
// 排除 Npgsql 和系统程序集
|
||||
var excludedAssemblies = new[]
|
||||
{
|
||||
"Npgsql",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL"
|
||||
};
|
||||
|
||||
var typeList = assemblies
|
||||
.Where(assembly =>
|
||||
{
|
||||
var assemblyName = assembly.GetName().Name ?? "";
|
||||
// 排除 Npgsql 相关程序集
|
||||
return !excludedAssemblies.Any(excluded =>
|
||||
assemblyName.StartsWith(excluded, StringComparison.OrdinalIgnoreCase));
|
||||
})
|
||||
.SelectMany(assembly =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return assembly.GetTypes();
|
||||
}
|
||||
catch (ReflectionTypeLoadException ex)
|
||||
{
|
||||
// 某些类型加载失败,只返回成功加载的类型
|
||||
return ex.Types.Where(t => t != null);
|
||||
}
|
||||
catch (TypeLoadException)
|
||||
{
|
||||
// 类型加载异常,跳过这个程序集
|
||||
return Enumerable.Empty<Type>();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 其他异常,跳过这个程序集
|
||||
return Enumerable.Empty<Type>();
|
||||
}
|
||||
})
|
||||
.Where(t => t != null && t.IsDefined(typeof(SelectResultAttribute), false));
|
||||
|
||||
foreach (var typeInfoItem in typeList)
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB386;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
||||
//"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB386;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
||||
"Default": "Host=192.168.111.174;Port=5432;Database=jisheiotprodb;Username=postgres;Password=JiShe!aqG#5kGgh&0;Encoding=UTF8;Pooling=true;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=100;"
|
||||
},
|
||||
"IoTDBOptions": {
|
||||
"UserName": "root",
|
||||
|
||||
@ -49,7 +49,7 @@ namespace JiShe.IoT.Domain.Shared
|
||||
/// 扩展属性,用于存储自定义字段,JSON格式
|
||||
/// </summary>
|
||||
[Comment("扩展属性,用于存储自定义字段,JSON格式")]
|
||||
[JsonMap]
|
||||
[JsonMap, Column(DbType = "jsonb")]
|
||||
public new ExtraPropertyDictionary ExtraProperties { get; set; } = new ExtraPropertyDictionary();
|
||||
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ namespace JiShe.IoT.Data
|
||||
|
||||
await MigrateDatabaseSchemaAsync();
|
||||
await SeedDataAsync();
|
||||
await InitIoTDBTable();
|
||||
//await InitIoTDBTable();
|
||||
|
||||
Logger.LogInformation($"Successfully completed host database migrations.");
|
||||
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
using JiShe.ServicePro.CTWingManagement.EntityFrameworkCore;
|
||||
using JiShe.ServicePro.CTWingManagement.EntityFrameworkCore;
|
||||
using JiShe.ServicePro.DeviceManagement.EntityFrameworkCore;
|
||||
using JiShe.ServicePro.DynamicMenuManagement.EntityFrameworkCore;
|
||||
using JiShe.ServicePro.FileManagement.EntityFrameworkCore;
|
||||
using JiShe.ServicePro.OneNETManagement.EntityFrameworkCore;
|
||||
using JiShe.ServicePro.TemplateManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.EntityFrameworkCore.PostgreSql;
|
||||
using Volo.Abp.Guids;
|
||||
using Volo.Abp.Timing;
|
||||
|
||||
namespace JiShe.IoT.EntityFrameworkCore
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(IoTDomainModule),
|
||||
typeof(AbpEntityFrameworkCoreMySQLPomeloModule),
|
||||
typeof(AbpEntityFrameworkCorePostgreSqlModule),
|
||||
typeof(BasicManagementEntityFrameworkCoreModule),
|
||||
typeof(DataDictionaryManagementEntityFrameworkCoreModule),
|
||||
typeof(NotificationManagementEntityFrameworkCoreModule),
|
||||
@ -27,10 +29,19 @@ namespace JiShe.IoT.EntityFrameworkCore
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
IoTEfCoreEntityExtensionMappings.Configure();
|
||||
|
||||
// ✅ 启用 Npgsql 旧版时间戳行为
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
// ✅ 配置 ABP 使用 UTC 时间
|
||||
Configure<AbpClockOptions>(options =>
|
||||
{
|
||||
options.Kind = DateTimeKind.Utc;
|
||||
});
|
||||
|
||||
context.Services.AddAbpDbContext<IoTDbContext>(options =>
|
||||
{
|
||||
/* Remove "includeAllEntities: true" to create
|
||||
@ -47,7 +58,7 @@ namespace JiShe.IoT.EntityFrameworkCore
|
||||
* See also HayoonKoreaDbContextFactory for EF Core tooling.
|
||||
* https://github.com/abpframework/abp/issues/21879
|
||||
* */
|
||||
options.UseMySQL(builder =>
|
||||
options.UseNpgsql(builder =>
|
||||
{
|
||||
builder.TranslateParameterizedCollectionsToConstants();
|
||||
});
|
||||
|
||||
@ -11,9 +11,8 @@ namespace JiShe.IoT.EntityFrameworkCore
|
||||
IoTEfCoreEntityExtensionMappings.Configure();
|
||||
|
||||
var configuration = BuildConfiguration();
|
||||
var serverVersion = new MySqlServerVersion(new Version(8, 4, 6));
|
||||
var builder = new DbContextOptionsBuilder<IoTDbContext>()
|
||||
.UseMySql(configuration.GetConnectionString("Default") , serverVersion);
|
||||
.UseNpgsql(configuration.GetConnectionString("Default"));
|
||||
|
||||
return new IoTDbContext(builder.Options);
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ global using Volo.Abp.BackgroundJobs;
|
||||
global using Volo.Abp.Data;
|
||||
global using Volo.Abp.DependencyInjection;
|
||||
global using Volo.Abp.EntityFrameworkCore;
|
||||
global using Volo.Abp.EntityFrameworkCore.MySQL;
|
||||
global using Volo.Abp.FeatureManagement;
|
||||
global using Volo.Abp.Identity;
|
||||
global using Volo.Abp.Modularity;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JiShe.IoT.Domain\JiShe.IoT.Domain.csproj" />
|
||||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL.Pomelo" />
|
||||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.14.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.14.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.14.0" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user