Abp: Unable to cast object of type 'System.Boolean' to type 'System.Int16'.”

Created on 10 Mar 2019  ·  5Comments  ·  Source: abpframework/abp

IdentityServerHost Mysql Init Application error,the log :

System.InvalidOperationException HResult=0x80131509 Message=No coercion operator is defined between types 'System.Int16' and 'System.Boolean'. Source=System.Linq.Expressions StackTrace: at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType) at System.Linq.Expressions.Expression.Convert(Expression expression, Type type, MethodInfo method) at System.Linq.Expressions.Expression.Convert(Expression expression, Type type) at Microsoft.EntityFrameworkCore.Storage.TypedRelationalValueBufferFactoryFactory.CreateGetValueExpression(Expression dataReaderExpression, Int32 index, TypeMaterializationInfo materializationInfo, Boolean detailedErrorsEnabled, Boolean box) at Microsoft.EntityFrameworkCore.Storage.TypedRelationalValueBufferFactoryFactory.<>c__DisplayClass13_0.<CreateArrayInitializer>b__0(TypeMaterializationInfo mi, Int32 i) at System.Linq.Enumerable.<SelectIterator>d__154`2.MoveNext() at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at System.Dynamic.Utils.CollectionExtensions.ToReadOnly[T](IEnumerable`1 enumerable) at System.Linq.Expressions.Expression.NewArrayInit(Type type, IEnumerable`1 initializers) at Microsoft.EntityFrameworkCore.Storage.TypedRelationalValueBufferFactoryFactory.CreateArrayInitializer(CacheKey cacheKey, Boolean detailedErrorsEnabled) at Microsoft.EntityFrameworkCore.Storage.TypedRelationalValueBufferFactoryFactory.<Create>b__11_0(CacheKey k) at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at Microsoft.EntityFrameworkCore.Storage.TypedRelationalValueBufferFactoryFactory.Create(IReadOnlyList`1 types) at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.CreateValueBufferFactory(IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory, DbDataReader dataReader) at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.<NotifyReaderCreated>b__14_0(FactoryAndReader s) at Microsoft.EntityFrameworkCore.Internal.NonCapturingLazyInitializer.EnsureInitialized[TParam,TValue](TValue& target, TParam param, Func`2 valueFactory) at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.NotifyReaderCreated(DbDataReader dataReader) at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.<BufferlessMoveNext>d__12.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.<MoveNext>d__11.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.AsyncSelectEnumerable`2.AsyncSelectEnumerator.<MoveNext>d__3.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Linq.AsyncEnumerable.<FirstOrDefault_>d__165`1.MoveNext() in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\First.cs:line 151 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.TaskResultAsyncEnumerable`1.Enumerator.<MoveNext>d__3.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator`2.<MoveNextCore>d__7.MoveNext() in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\Select.cs:line 118 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Linq.AsyncEnumerable.AsyncIterator`1.<MoveNext>d__10.MoveNext() in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\AsyncIterator.cs:line 112 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.<MoveNext>d__5.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<ExecuteSingletonAsyncQuery>d__21`1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Volo.Abp.IdentityServer.Clients.ClientRepository.<FindByCliendIdAsync>d__1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Volo.Abp.Uow.UnitOfWorkInterceptor.<InterceptAsync>d__4.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Volo.Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult>d__7`1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at IdentityServerHost.IdentityServerDataSeeder.<SeedAsync>d__5.MoveNext() in G:\LocalHost\Git\gitee\C#\BaseFramework\host\IdentityServerHost\IdentityServerDataSeeder.cs:line 35 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func`1 action) at IdentityServerHost.IdentityServerDataSeeder.Seed() in G:\LocalHost\Git\gitee\C#\BaseFramework\host\IdentityServerHost\IdentityServerDataSeeder.cs:line 30 at IdentityServerHost.IdentityServerHostModule.SeedData(ApplicationInitializationContext context) in G:\LocalHost\Git\gitee\C#\BaseFramework\host\IdentityServerHost\IdentityServerHostModule.cs:line 78 at IdentityServerHost.IdentityServerHostModule.OnApplicationInitialization(ApplicationInitializationContext context) in G:\LocalHost\Git\gitee\C#\BaseFramework\host\IdentityServerHost\IdentityServerHostModule.cs:line 71 at Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context) at Volo.Abp.AbpApplicationBase.InitializeModules() at IdentityServerHost.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in G:\LocalHost\Git\gitee\C#\BaseFramework\host\IdentityServerHost\Startup.cs:line 24

Most helpful comment

https://github.com/aspnet/EntityFrameworkCore/issues/14051
This looks like an issue with the MySQL provider.
@Jesn
you might want to try the Pomelo.EntityFrameworkCore.MySql
in 0.15 Pomelo.EntityFrameworkCore.MySql has been integrated.
or manual integrate

  1. remove Volo.Abp.EntityFrameworkCore.MySql package from xxx.EntityFrameworkCore.csproj
  2. add Pomelo.EntityFrameworkCore.MySql package into xxx.EntityFrameworkCore.csproj
  3. edit ConfigureDatabaseServices method,
private void ConfigureDatabaseServices()
{
    Configure<AbpDbContextOptions>(options =>
    {
        options.Configure(context =>
        {
            if (context.ExistingConnection != null)
            {
                context.DbContextOptions.UseMySql(context.ExistingConnection);
            }
            else
            {
                context.DbContextOptions.UseMySql(context.ConnectionString);
            }
        });
    });
}

All 5 comments

How to repro?

https://github.com/aspnet/EntityFrameworkCore/issues/14051
This looks like an issue with the MySQL provider.
@Jesn
you might want to try the Pomelo.EntityFrameworkCore.MySql
in 0.15 Pomelo.EntityFrameworkCore.MySql has been integrated.
or manual integrate

  1. remove Volo.Abp.EntityFrameworkCore.MySql package from xxx.EntityFrameworkCore.csproj
  2. add Pomelo.EntityFrameworkCore.MySql package into xxx.EntityFrameworkCore.csproj
  3. edit ConfigureDatabaseServices method,
private void ConfigureDatabaseServices()
{
    Configure<AbpDbContextOptions>(options =>
    {
        options.Configure(context =>
        {
            if (context.ExistingConnection != null)
            {
                context.DbContextOptions.UseMySql(context.ExistingConnection);
            }
            else
            {
                context.DbContextOptions.UseMySql(context.ConnectionString);
            }
        });
    });
}

@akinix Thanks for highlighting that!

@akinix I 've alreadly handled it in your way,tha's ok, thanks!

I think this is fixed since we moved to Pomelo driver https://github.com/abpframework/abp/pull/855

Was this page helpful?
0 / 5 - 0 ratings