abp icon indicating copy to clipboard operation
abp copied to clipboard

`MySQL` SQL tree does not have a type mapping assigned.

Open andylaufzf opened this issue 1 month ago • 15 comments

Is there an existing issue for this?

  • [ ] I have searched the existing issues

Description

Our project update from 9.3.6 to 10.0.0,Running the 'DbMigrator' project prompts an error, private async Task SeedDataAsync(Tenant? tenant = null) { Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed...");

 await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id)
     .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName,
         BookStoreConsts.AdminEmailDefaultValue)
     .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName,
         BookStoreConsts.AdminPasswordDefaultValue)
 );

} The erro detail: System.InvalidOperationException HResult=0x80131509 Message=Expression '@names' in the SQL tree does not have a type mapping assigned. Source=Microsoft.EntityFrameworkCore.Relational StackTrace: 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.VisitExtension(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.SqlExpressions.InExpression.VisitChildren(ExpressionVisitor visitor) 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.VisitExtension(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.SqlExpressions.SqlBinaryExpression.VisitChildren(ExpressionVisitor visitor) 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.VisitExtension(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.SqlExpressions.SqlBinaryExpression.VisitChildren(ExpressionVisitor visitor) 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.VisitExtension(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.SqlExpressions.SqlBinaryExpression.VisitChildren(ExpressionVisitor visitor) 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.VisitExtension(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression.VisitChildren(ExpressionVisitor visitor) 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.VisitExtension(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.VisitExtension(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.RelationalTypeMappingPostprocessor.Process(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.RelationalQueryTranslationPostprocessor.ProcessTypeMappings(Expression expression) 在 Microsoft.EntityFrameworkCore.Query.RelationalQueryTranslationPostprocessor.Process(Expression query) 在 MySql.EntityFrameworkCore.Query.Internal.MySQLQueryTranslationPostprocessor.Process(Expression query) 在 Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutorExpression[TResult](Expression query) 在 Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) 在 Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass11_01.<ExecuteCore>b__0() 在 Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func1 compiler) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken) 在 Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken) 在 Volo.Abp.EntityFrameworkCore.AbpEntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken) 在 Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable1.GetAsyncEnumerator(CancellationToken cancellationToken) 在 System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable1.GetAsyncEnumerator() 在 Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.<ToListAsync>d__671.MoveNext() 在 Volo.Abp.PermissionManagement.EntityFrameworkCore.EfCorePermissionGrantRepository.<GetListAsync>d__3.MoveNext() 在 Castle.DynamicProxy.AsyncInterceptorBase.<ProceedAsynchronous>d__141.MoveNext() 在 Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.<ProceedAsync>d__7.MoveNext() 在 Volo.Abp.Uow.UnitOfWorkInterceptor.<InterceptAsync>d__2.MoveNext() 在 Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__31.MoveNext() 在 Volo.Abp.PermissionManagement.PermissionDataSeeder.<SeedAsync>d__10.MoveNext() 在 Volo.Abp.PermissionManagement.PermissionDataSeedContributor.<SeedAsync>d__10.MoveNext() 在 Volo.Abp.Data.DataSeeder.<SeedAsync>d__7.MoveNext() 在 Castle.DynamicProxy.AsyncInterceptorBase.<ProceedAsynchronous>d__13.MoveNext() 在 Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.<ProceedAsync>d__7.MoveNext() 在 Volo.Abp.Uow.UnitOfWorkInterceptor.<InterceptAsync>d__2.MoveNext() 在 Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__2.MoveNext() 在 Acme.BookStore.Data.BookStoreDbMigrationService.<SeedDataAsync>d__11.MoveNext() 在 E:\Projects\XTime\FreamWork\test5\Acme.BookStore\src\Acme.BookStore.Domain\Data\BookStoreDbMigrationService.cs 中: 第 108 行 在 Acme.BookStore.Data.BookStoreDbMigrationService.<MigrateAsync>d__9.MoveNext() 在 E:\Projects\XTime\FreamWork\test5\Acme.BookStore\src\Acme.BookStore.Domain\Data\BookStoreDbMigrationService.cs 中: 第 54 行 在 Acme.BookStore.DbMigrator.DbMigratorHostedService.<StartAsync>d__3.MoveNext() 在 E:\Projects\XTime\FreamWork\test5\Acme.BookStore\src\Acme.BookStore.DbMigrator\DbMigratorHostedService.cs 中: 第 36 行 在 Microsoft.Extensions.Hosting.Internal.Host.<<StartAsync>b__14_1>d.MoveNext() 在 Microsoft.Extensions.Hosting.Internal.Host.<ForeachService>d__17`1.MoveNext()

Reproduction Steps

No response

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

10.0.0

User Interface

MVC

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

Windows (Default)

Other information

No response

andylaufzf avatar Nov 18 '25 19:11 andylaufzf

Image

Image how can I fix this bugs after upgrade from EF8 to EF 10,and abp vnext 8 to abp framework 10, it just can't work properly. when I use [pomelo-provider] issue, it happens like this .pomelo-provider

BarryJame avatar Nov 19 '25 01:11 BarryJame

how to fix this bugs ? what steps ?

BarryJame avatar Nov 19 '25 01:11 BarryJame

hi

This is the current situation with the MySQL EF Core provider:

  • Pomelo.EntityFrameworkCore.MySql does not yet support .NET 10.0.
  • MySql.EntityFrameworkCore is still RC and has some bugs.

We need to wait for them to fix the bugs and support the latest .NET 10. After that, you can consider upgrading to ABP 10.0.

Thanks.

maliming avatar Nov 19 '25 01:11 maliming

ok,thks, when about this issue fix ? and how can we get fix notifications in the first time ?

BarryJame avatar Nov 19 '25 02:11 BarryJame

Please follow:

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/2007 https://www.nuget.org/packages/MySql.EntityFrameworkCore/#versions-body-tab

We will upgrade them once the new version is available.

maliming avatar Nov 19 '25 02:11 maliming

I believe this is the relevant bug in MySql.EntityFrameworkCore:

https://bugs.mysql.com/bug.php?id=119461

hillin avatar Nov 25 '25 15:11 hillin

I opened the fix PR but didn't merge it.

https://bugs.mysql.com/bug.php?id=119338

maliming avatar Nov 26 '25 01:11 maliming

I opened the fix PR but didn't merge it.

https://bugs.mysql.com/bug.php?id=119338

Great! But they do not seem to be the same problem, isn't it? If I understand correctly, this issue is related to the translation of the .Contains LINQ operator - or did you also fix it along with the .StartsWith/.EndsWith operators?

hillin avatar Nov 26 '25 03:11 hillin

FYI I can narrow down the exception down to this line:

https://github.com/abpframework/abp/blob/4a93da58db327dbb0aa17644ca94180f91d7c1b5/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionGrantRepository.cs#L55C17-L55C41

Clearly the .Contains clause did not get translated correctly.

hillin avatar Nov 26 '25 03:11 hillin

hi @hillin

The Contains method has breaking changes in EF Core 10.0, the MySQL provider also needs to be compatible with it.

https://github.com/dotnet/efcore/pull/35339/commits/d10b625140320c000d1fd9b25fdce2c25397a853

In short, we need to wait for the MySQL provider to support EF Core 10.0.

Thanks.

maliming avatar Nov 26 '25 05:11 maliming

@maliming Exactly.

I can see in .NET 10, this code has been compiled to use ReadOnlySpan<string>.Contains:

Decompiled code: Image

Perhaps we can work around it by explicitly casting the names array to IEnumerable<string>?

hillin avatar Nov 26 '25 05:11 hillin

hi

explicitly casting the names array to IEnumerable?

This is the responsibility of the EF Core provider. SQL Server/SQLite/PostgreSQL providers have no problem.

Thanks.

maliming avatar Nov 26 '25 05:11 maliming

Sure, just suggesting a workaround until it's fixed on the mysql connector side.

hillin avatar Nov 26 '25 05:11 hillin

Is there any progress or plan?

zengande avatar Nov 27 '25 05:11 zengande

hi @zengande

we need to wait for the MySQL provider to support EF Core 10.0.

maliming avatar Nov 27 '25 07:11 maliming