Starts in:
2 DAYS
3 HRS
1 MIN
41 SEC
Starts in:
2 D
3 H
1 M
41 S
Open Closed

OpenIddictProDbContext error when OpenIddict 4.x to 5.x Migration #6464


User avatar
0
IbrahimSarigoz created

Hello, I successfully moved my project from .net 7 to .net 8. My problem occurs while updating OpenIddict. When I run migrate, it gives me an error like this:

 An exception occurred while iterating over the results of a query for context type 'Volo.Abp.OpenIddict.EntityFrameworkCore.OpenIddictProDbContext'. 
 Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-00904: "o"."ClientType": invalid identifier                      
 at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType,
 Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)             
 at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl,
 CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, 
 OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, 
 Boolean& bBindParamPresent, Int64& internalInitialLOBFS, Int64 internalInitialJSONFS, OracleException& exceptionForArrayBindDML, OracleConnection
 connection, IEnumerable`1 adrianParsedStmt, Boolean isDescribeOnly, Boolean isFromEF)
 at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) 
 at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
 at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
 --- End of stack trace from previous location --- 
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)                                              
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)                                          
 at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
 Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-00904: "o"."ClientType": invalid identifier
 at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount,
 OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)
 at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, Int64 internalInitialJSONFS, OracleException& exceptionForArrayBindDML, OracleConnection connection, IEnumerable`1 adrianParsedStmt, Boolean isDescribeOnly, Boolean isFromEF)
 at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
 at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
 at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
 --- End of stack trace from previous location --- 
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
 at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
 at Volo.Abp.OpenIddict.Applications.EfCoreOpenIddictApplicationRepository.FindByClientIdAsync(String clientId, CancellationToken cancellationToken)         
 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)   
 
 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()                                      
 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)                                              
 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)         
 at MyBankStore.OpenIddict.OpenIddictDataSeedContributor.CreateApplicationAsync(String name, String type, String consentType, String displayName, String secret, List`1 grantTypes, List`1 scopes, String redirectUri, String postLogoutRedirectUri, List`1 permissions, String clientUri, String logoUri) in D:\\MyBankStore\src\MyBankStore.Domain\OpenIddict\OpenIddictDataSeedContributor.cs:line 344        
 Unhandled exception.    at MyBankStore.OpenIddict.OpenIddictDataSeedContributor.CreateApplicationsAsync() in D:\\MyBankStore\src\MyBankStore.Domain\OpenIddict\OpenIddictDataSeedContributor.cs:line 90                                                                  
 at MyBankStore.OpenIddict.OpenIddictDataSeedContributor.SeedAsync(DataSeedContext context) in D:\\MyBankStore\src\MyBankStore.Domain\OpenIddict\OpenIddictDataSeedContributor.cs:line 56   
 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo)Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-00904: "o"."ClientType": invalid identifier  
 at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)       
 at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, Int64 internalInitialJSONFS, OracleException& exceptionForArrayBindDML, OracleConnection connection, IEnumerable`1 adrianParsedStmt, Boolean isDescribeOnly, Boolean isFromEF) 
 at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)             
 at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)                                         
 at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) 
 --- End of stack trace from previous location ---     
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)           
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)               
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)            
 at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)                                                                               
 at Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)                                                                               
 at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()        
 at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)                                                                                                           
 at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)                                                     
 at Volo.Abp.OpenIddict.Applications.EfCoreOpenIddictApplicationRepository.FindByClientIdAsync(String clientId, CancellationToken cancellationToken)                                                                                                                                             
 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)     
 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()      
 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)                   
 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)                                                                                                                         

 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync()                                                             
 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)                        
 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)                                      
 at Volo.Abp.Data.DataSeeder.SeedAsync(DataSeedContext context)                                                                 
 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo)                   
 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync()                                                               
 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)                                                      
 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)                                                                                            at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)                                 at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)                                                                                              at Microsoft.Extensions.Hosting.Internal.Host.&lt;StartAsync&gt;g__LogAndRethrow|15_3(&lt;&gt;c__DisplayClass15_0&)                                            at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)                                                      at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)                                    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)                              
 at MyBankStore.DbMigrator.Program.Main(String[] args) in D:\\MyBankStore\src\MyBankStore.DbMigrator\Program.cs:line 28        
 at MyBankStore.DbMigrator.Program.&lt;Main&gt;(String[] args)                                                                     
 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync()                                   
 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)                            
 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)           
 at Volo.Abp.Data.DataSeeder.SeedAsync(DataSeedContext context)                                                                  
 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo)        
 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync()                                                     
 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)    
 

I updated all my packages via Suite and such a problem occurs.

I am trying to migrate in the link https://docs.abp.io/en/abp/8.0/Migration-Guides/OpenIddict4-to-5#openiddictapplicationmodel-changes We work in Oracle database. Could there be a problem with Volo.Abp.OpenIddict.Pro Version="8.0.1"?

  • ABP Framework version: v8.0.1
  • UI Type: MVC
  • Database System: Oracle
  • Tiered (for MVC) or Auth Server Separated (for Angular): Tiered

16 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Did you add the new ef core migrations? Can you share the migration file?

    btw, It seems the Oracle didn't support ef core 8.

  • User Avatar
    0
    IbrahimSarigoz created

    Yes i added new migration :

    using System;
    using Microsoft.EntityFrameworkCore.Migrations;
    
    #nullable disable
    
    namespace MyBankStore.Migrations
    {
        /// <inheritdoc />
        public partial class Updated_OpenIddict : Migration
        {
            /// <inheritdoc />
            protected override void Up(MigrationBuilder migrationBuilder)
            {
                migrationBuilder.RenameColumn(
                    name: "Type",
                    table: "OpenIddictApplications",
                    newName: "ClientType");
    
                migrationBuilder.AddColumn<string>(
                    name: "ApplicationType",
                    table: "OpenIddictApplications",
                    type: "nvarchar(50)",
                    maxLength: 50,
                    nullable: true);
    
                migrationBuilder.AddColumn<string>(
                    name: "JsonWebKeySet",
                    table: "OpenIddictApplications",
                    type: "nvarchar(max)",
                    nullable: true);
    
                migrationBuilder.AddColumn<string>(
                    name: "Settings",
                    table: "OpenIddictApplications",
                    type: "nvarchar(max)",
                    nullable: true);
            }
    
            /// <inheritdoc />
            protected override void Down(MigrationBuilder migrationBuilder)
            {
                migrationBuilder.DropColumn(
                    name: "ApplicationType",
                    table: "OpenIddictApplications");
    
                migrationBuilder.DropColumn(
                    name: "JsonWebKeySet",
                    table: "OpenIddictApplications");
    
                migrationBuilder.DropColumn(
                    name: "Settings",
                    table: "OpenIddictApplications");
    
                migrationBuilder.RenameColumn(
                    name: "ClientType",
                    table: "OpenIddictApplications",
                    newName: "Type");
            }
        }
    }
    
    

    I changed this part as well

       var application = new AbpApplicationDescriptor {
           ClientId = name,
           ClientType = type,
           ClientSecret = secret,
           ConsentType = consentType,
           DisplayName = displayName,
           ClientUri = clientUri,
           LogoUri = logoUri,
       };
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The migration file looks no problem,

    I'm sure you have update database with the migration file.

    Please check the table columns in the database.

  • User Avatar
    0
    IbrahimSarigoz created

    What does update database mean? I add this file myself and i didnt change anything else. While developing in .net7, we were using abp 7 version. And the migration was working without any problems. With my migration to abp 8, I added only the migration file I sent you for openIddict to the Migrations folder. and now when it goes to the migration seed data section it gives me the error I got.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You need to update your database with your migrations.

    You should use dotnet ef migrations add Updated_OpenIddict command to add new migrations instead of copy the code from https://docs.abp.io/en/abp/8.0/Migration-Guides/OpenIddict4-to-5#openiddictapplicationmodel-changes

    After creating new migrations you can use dotnet ef database update to update the database.

    https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli

  • User Avatar
    0
    IbrahimSarigoz created

    I update the database it gives this error.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    It seems your ef core migration files are not generated by Oracle provider.

    Please check it and make sure your db provider is Oracle.

  • User Avatar
    0
    IbrahimSarigoz created

    We are using a suite and it creates all of entities for oracle so I dont think provider is a problem.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a project?

    liming.ma@volosoft.com

  • User Avatar
    0
    IbrahimSarigoz created

    Which part do you want me to share with you?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share an entire project?

    or the ef core project MyCompanyName.MyProjectName.EntityFrameworkCore

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I successfully moved my project from .net 7 to .net 8.

    But your ef project is still using abp 7 and ef 7.

  • User Avatar
    0
    IbrahimSarigoz created

    Since OpenIddict was not migrated automatically, we had to downgrade the project. As I explained in the e-mail, we have to continue writing code. The problem is, when I create the migration file I sent you above by adding and updating it as in the link you sent, we try it on the test database. and it gives the error I sent above.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Sorry, I missed your messages.

    Can you find a way to reproduce this problem in a project?

  • User Avatar
    0
    IbrahimSarigoz created

    Hi, I solved my problem. Here I would like to write an explanation for people who may encounter the same problem. First make sure you have successfully upgraded all your project's nuget packages. Some nuget packages may need to remain in the same version, depending on your project. For example, in my case, since .net 8 was not supported, the System.ServiceModel nuget packages had to remain in version 4.4.*. This may be another nuget package or another version in your project. var application = new AbpApplicationDescriptor { ClientId = name, ClientType = type, ClientSecret = secret, ConsentType = consentType, DisplayName = displayName, ClientUri = clientUri, LogoUri = logoUri, }; Don't forget to change Type to ClientType.

    After checking these, make sure that the project is built successfully. Run "dotnet ef migrations add Updated_OpenIddict" in the EntityFrameworkCore project. In this way, you will migrate the necessary entity changes to your project. Finally, if DbMigrator gives an error due to old settings, run the "dotnet ef database update" code in your EntityFrameworkCore project.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06