Pomelo迁移失败

This commit is contained in:
陈益 2025-12-07 11:03:48 +08:00
parent 26d4db8f92
commit 94af3c9a7f
10 changed files with 68 additions and 15 deletions

View File

@ -19,7 +19,7 @@
<PackageReference Update="Volo.Abp.BackgroundJobs.HangFire" Version="$(VoloAbpVersion)"/>
<PackageReference Update="Volo.Abp.AspNetCore.SignalR" Version="$(VoloAbpVersion)"/>
<PackageReference Update="Volo.Abp.TestBase" Version="$(VoloAbpVersion)"/>
<PackageReference Update="Volo.Abp.EntityFrameworkCore.MySQL" Version="$(VoloAbpVersion)"/>
<PackageReference Update="Volo.Abp.EntityFrameworkCore.MySQL.Pomelo" Version="$(VoloAbpVersion)"/>
<PackageReference Update="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpVersion)"/>
<PackageReference Update="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(VoloAbpVersion)"/>
<PackageReference Update="Volo.Abp.Identity.EntityFrameworkCore" Version="$(VoloAbpVersion)"/>

View File

@ -102,8 +102,13 @@
<PackageReference Update="Scriban" Version="5.4.4" />
<PackageReference Update="Otp.NET" Version="1.4.0" />
<PackageReference Update="QRCoder" Version="1.6.0" />
<PackageReference Update="QRCoder" Version="1.7.0" />
<!--SixLabors.ImageSharp-->
<PackageReference Update="SixLabors.ImageSharp" Version="3.1.12" />
<!--MySql.EntityFrameworkCore-->
<PackageReference Update="MySql.EntityFrameworkCore" Version="10.0.0-rc" />
</ItemGroup>
</Project>

@ -1 +1 @@
Subproject commit 323492e10b2937a063c9e60b26bc40c6954503c7
Subproject commit c3d3ced4b1a82967373e389877632349afee0de0

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="JiSheTeam" value="http://192.168.111.248:9511/nuget/JiSheTeam/v3/index.json" protocolVersion="3" allowInsecureConnections="true" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="JiSheTeam" value="http://localhost:5020/v3/index.json" protocolVersion="3" allowInsecureConnections="true" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" allowInsecureConnections="True" />
</packageSources>
</configuration>

View File

@ -33,7 +33,6 @@
<PackageReference Include="Serilog.Sinks.File" />
<PackageReference Include="Serilog.Sinks.Async" />
<PackageReference Include="Hangfire.Redis.StackExchange" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" />
<PackageReference Include="DotNetCore.CAP.MySql" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" />

View File

@ -1,14 +1,14 @@
{
"ConnectionStrings": {
"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
"Default": "Data Source=localhost;Port=33306;Database=JiSheIoTProDB3;uid=root;pwd=123456789;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=Preferred;Pooling=true;"
},
"IoTDBOptions": {
"UserName": "root",
"Password": "Lixiao@1980",
//"TreeModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ],
//"TableModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ],
"TreeModelClusterList": [ "192.168.111.174:30710" ],
"TableModelClusterList": [ "192.168.111.174:30710" ],
"TreeModelClusterList": [ "47.110.53.196:30710" ],
"TableModelClusterList": [ "47.110.53.196:30710" ],
"PoolSize": 32,
"DataBaseName": "jisheiotdata",
"OpenDebugMode": false,

View File

@ -4,13 +4,14 @@ using JiShe.ServicePro.DynamicMenuManagement.EntityFrameworkCore;
using JiShe.ServicePro.FileManagement.EntityFrameworkCore;
using JiShe.ServicePro.OneNETManagement.EntityFrameworkCore;
using JiShe.ServicePro.TemplateManagement.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.MySQL;
using Volo.Abp.Guids;
namespace JiShe.IoT.EntityFrameworkCore
{
[DependsOn(
typeof(IoTDomainModule),
typeof(AbpEntityFrameworkCoreMySQLModule),
typeof(AbpEntityFrameworkCoreMySQLPomeloModule),
typeof(BasicManagementEntityFrameworkCoreModule),
typeof(DataDictionaryManagementEntityFrameworkCoreModule),
typeof(NotificationManagementEntityFrameworkCoreModule),
@ -37,6 +38,10 @@ namespace JiShe.IoT.EntityFrameworkCore
* default repositories only for aggregate roots */
options.AddDefaultRepositories(includeAllEntities: true);
});
//// 注册自定义的IdentityUserRepository以修复ABP 10.0.1与MySQL的兼容性问题
//context.Services.AddTransient<Volo.Abp.Identity.IIdentityUserRepository, IoTIdentityUserRepository>();
Configure<AbpSequentialGuidGeneratorOptions>(options =>
{
options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsString;

View File

@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;
namespace JiShe.IoT.EntityFrameworkCore
{
/// <summary>
/// 自定义IdentityUserRepository修复ABP 10.0.1与MySQL提供程序的兼容性问题
/// 解决 "Expression '@organizationUnitIds' in the SQL tree does not have a type mapping assigned" 错误
/// </summary>
public class IoTIdentityUserRepository : Volo.Abp.Identity.EntityFrameworkCore.EfCoreIdentityUserRepository
{
public IoTIdentityUserRepository(
IDbContextProvider<IoTDbContext> dbContextProvider)
: base((IDbContextProvider<Volo.Abp.Identity.EntityFrameworkCore.IIdentityDbContext>)dbContextProvider)
{
}
public override async Task<List<string>> GetRoleNamesAsync(Guid id, CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
// 使用Join查询来避免参数化集合查询的问题
// 这样可以避免EF Core将集合参数转换为SQL参数时出现的类型映射问题
var roleNames = await (from user in dbContext.Users
join userRole in dbContext.Set<IdentityUserRole>() on user.Id equals userRole.UserId
join role in dbContext.Roles on userRole.RoleId equals role.Id
where user.Id == id
select role.Name)
.Distinct()
.ToListAsync(GetCancellationToken(cancellationToken));
return roleNames ?? new List<string>();
}
}
}

View File

@ -9,9 +9,10 @@ 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"));
.UseMySql(configuration.GetConnectionString("Default"), serverVersion);
return new IoTDbContext(builder.Options);
}

View File

@ -3,11 +3,16 @@
<TargetFramework>$(DotnetTargetFrameworkVersion)</TargetFramework>
<RootNamespace>JiShe.IoT</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Remove="EntityFrameworkCore\IoTIdentityUserRepository.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JiShe.IoT.Domain\JiShe.IoT.Domain.csproj" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" />
</ItemGroup>
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL.Pomelo" />
<!--<PackageReference Include="MySql.EntityFrameworkCore" />-->
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug'" Label="Debug">
<ProjectReference Include="..\..\JiShe.ServicePro\modules\BasicManagement\src\JiShe.ServicePro.BasicManagement.EntityFrameworkCore\JiShe.ServicePro.BasicManagement.EntityFrameworkCore.csproj" />