Open Closed

DBMigration error #2680


User avatar
0
shobhit created
  • ABP Framework version: v5.1.4
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:https://aztutehealth-my.sharepoint.com/:t:/g/personal/chitra_aztute_com/EQ7KofEDvsRDksVInhZZTLgB34KYPfimDMSJu2jQmtoGYw
  • Steps to reproduce the issue:"
  1. download latest abp application 5.1.4
  2. setup 2 db
    1. 1st with default connection for application
    2. 2nd with AbpIdentity for identity server
  3. in DBMigrator set both connection strings
  4. run dbmigrator
  5. Wola. you got the error

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

    run dbmigrator

    How do you run it?

    Can you try to usedotnet run?

  • User Avatar
    0
    shobhit created

    i am using windows 11 with visual studio 2022. i use the above command also but same result

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can I check?

    https://zoom.us/j/98800628842?pwd=RzlYV0tzU2NqVEZJWFBRVURUVUgwdz09

  • User Avatar
    0
    shobhit created

    sure

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    See https://docs.abp.io/en/abp/latest/Entity-Framework-Core-Migrations#create-a-second-dbcontext

  • User Avatar
    0
    shobhit created

    Hello Maliming, after following all instructions, my inputs are:

    1. identity tables not created in business tables
    2. identity tables not created in identity db
    3. still getting same error

    not sure what else i am missing

  • User Avatar
    0
    shobhit created

    Hello Maliming, i realized my dbmgiration initial class was missing the table creation. something missing. anyway i copied the db migration manually in migration class. now i am getting this error:

    Microsoft.Data.SqlClient.SqlException HResult=0x80131904 Message=Invalid object name 'IdentityServerIdentityResources'. Source=Core Microsoft SqlClient Data Provider StackTrace: at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please create a new project and send it to me, I will write some code for you. liming.ma@volosoft.com

    abp new QA -t app-pro --separate-tenant-schema
    
  • User Avatar
    0
    shobhit created

    fixed this. but getting another issue with error message Invalid object name "IdentityServerIdentityResources"

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Invalid object name "IdentityServerIdentityResources"

    Full error logs?

  • User Avatar
    0
    shobhit created

    https://aztutehealth-my.sharepoint.com/:t:/g/personal/shobhit_aztute_com/EQfUhDgW76BMgJd6QHUpEVoB3zfq3OXubrj3dpoFQhJB8Q

  • User Avatar
    0
    shobhit created

    tables has been created in respective databases but data seed is failing

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    https://support.abp.io/QA/Questions/2680#answer-66c50306-894d-cb9f-6ca2-3a02758a3d5a

  • User Avatar
    0
    shobhit created

    email sent with generated code

  • User Avatar
    0
    shobhit created

    Thanks Maliming. Please confirm if changes are only in *.EntityFrameoworkCore project only. You have also provided 3 commands. how exactly i should run them

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    if changes are only in *.EntityFrameoworkCore project only

    Yes,

    You have also provided 3 commands. how exactly i should run them

    Run it on EntityFrameoworkCore project folder to add init migrations.

  • User Avatar
    0
    shobhit created

    [16:43:07 ERR] Failed executing DbCommand (246ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean), @__ef_filter__p_1='?' (DbType = Boolean), @__normalizedUserName_0='?' (Size = 256)], CommandType='Text', CommandTimeout='30'] SELECT TOP(1) [a].[Id], [a].[AccessFailedCount], [a].[ConcurrencyStamp], [a].[CreationTime], [a].[CreatorId], [a].[DeleterId], [a].[DeletionTime], [a].[Email], [a].[EmailConfirmed], [a].[ExtraProperties], [a].[IsActive], [a].[IsDeleted], [a].[IsExternal], [a].[LastModificationTime], [a].[LastModifierId], [a].[LockoutEnabled], [a].[LockoutEnd], [a].[Name], [a].[NormalizedEmail], [a].[NormalizedUserName], [a].[PasswordHash], [a].[PhoneNumber], [a].[PhoneNumberConfirmed], [a].[SecurityStamp], [a].[Surname], [a].[TenantId], [a].[TwoFactorEnabled], [a].[UserName] FROM [AbpUsers] AS [a] WHERE (((@__ef_filter__p_0 = CAST(1 AS bit)) OR ([a].[IsDeleted] = CAST(0 AS bit))) AND ((@__ef_filter__p_1 = CAST(1 AS bit)) OR [a].[TenantId] IS NULL)) AND ([a].[NormalizedUserName] = @__normalizedUserName_0) ORDER BY [a].[Id] [16:43:07 ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.Identity.EntityFrameworkCore.IdentityProDbContext'. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AbpUsers'. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() ClientConnectionId:1ccd7bca-c260-4896-8868-4f8c3a9f03f7 Error Number:208,State:1,Class:16

  • User Avatar
    0
    shobhit created

    in EntitytFrameworkCore --> onModelCreating() i have commented out

    //builder.ConfigureIdentityPro(); //builder.ConfigureIdentityServer();

    while you have commented only //builder.ConfigureIdentityPro();

    is this problem?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Yes, If you commented out the IdentityServer

    You need to recreate all migrations for the host and tenant and IdentityServer+identity.

    dotnet ef migrations add Initial --context QADbContext
    dotnet ef migrations add Initial --context QATenantDbContext --output-dir Migrations/Tenant
    dotnet ef migrations add Initial --context QAIdentityDbContext --output-dir Migrations/Identity
    
  • User Avatar
    0
    shobhit created

    Run all 3 above commands but still got the error: [16:57:16 ERR] Failed executing DbCommand (261ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean), @__ef_filter__p_1='?' (DbType = Boolean), @__normalizedUserName_0='?' (Size = 256)], CommandType='Text', CommandTimeout='30'] SELECT TOP(1) [a].[Id], [a].[AccessFailedCount], [a].[ConcurrencyStamp], [a].[CreationTime], [a].[CreatorId], [a].[DeleterId], [a].[DeletionTime], [a].[Email], [a].[EmailConfirmed], [a].[ExtraProperties], [a].[IsActive], [a].[IsDeleted], [a].[IsExternal], [a].[LastModificationTime], [a].[LastModifierId], [a].[LockoutEnabled], [a].[LockoutEnd], [a].[Name], [a].[NormalizedEmail], [a].[NormalizedUserName], [a].[PasswordHash], [a].[PhoneNumber], [a].[PhoneNumberConfirmed], [a].[SecurityStamp], [a].[Surname], [a].[TenantId], [a].[TwoFactorEnabled], [a].[UserName] FROM [AbpUsers] AS [a] WHERE (((@__ef_filter__p_0 = CAST(1 AS bit)) OR ([a].[IsDeleted] = CAST(0 AS bit))) AND ((@__ef_filter__p_1 = CAST(1 AS bit)) OR [a].[TenantId] IS NULL)) AND ([a].[NormalizedUserName] = @__normalizedUserName_0) ORDER BY [a].[Id] [16:57:16 ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.Identity.EntityFrameworkCore.IdentityProDbContext'. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AbpUsers'. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

  • User Avatar
    0
    shobhit created

    Full log: [17:09:14 ERR] Failed executing DbCommand (264ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean), @__ef_filter__p_1='?' (DbType = Boolean), @__normalizedUserName_0='?' (Size = 256)], CommandType='Text', CommandTimeout='30'] SELECT TOP(1) [a].[Id], [a].[AccessFailedCount], [a].[ConcurrencyStamp], [a].[CreationTime], [a].[CreatorId], [a].[DeleterId], [a].[DeletionTime], [a].[Email], [a].[EmailConfirmed], [a].[ExtraProperties], [a].[IsActive], [a].[IsDeleted], [a].[IsExternal], [a].[LastModificationTime], [a].[LastModifierId], [a].[LockoutEnabled], [a].[LockoutEnd], [a].[Name], [a].[NormalizedEmail], [a].[NormalizedUserName], [a].[PasswordHash], [a].[PhoneNumber], [a].[PhoneNumberConfirmed], [a].[SecurityStamp], [a].[Surname], [a].[TenantId], [a].[TwoFactorEnabled], [a].[UserName] FROM [AbpUsers] AS [a] WHERE (((@__ef_filter__p_0 = CAST(1 AS bit)) OR ([a].[IsDeleted] = CAST(0 AS bit))) AND ((@__ef_filter__p_1 = CAST(1 AS bit)) OR [a].[TenantId] IS NULL)) AND ([a].[NormalizedUserName] = @__normalizedUserName_0) ORDER BY [a].[Id] [17:09:14 ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.Identity.EntityFrameworkCore.IdentityProDbContext'. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AbpUsers'. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() ClientConnectionId:44e01202-8f07-4399-bf02-561dd2ae6ef5 Error Number:208,State:1,Class:16 Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AbpUsers'. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable1 asyncEnumerable, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable1 asyncEnumerable, CancellationToken cancellationToken) at Volo.Abp.Identity.EntityFrameworkCore.EfCoreIdentityUserRepository.FindByNormalizedUserNameAsync(String normalizedUserName, Boolean includeDetails, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.Identity.IdentityDataSeeder.SeedAsync(String adminEmail, String adminPassword, Nullable1 tenantId) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Volo.Abp.Data.DataSeeder.SeedAsync(DataSeedContext context) ClientConnectionId:44e01202-8f07-4399-bf02-561dd2ae6ef5 Error Number:208,State:1,Class:16

  • User Avatar
    0
    shobhit created

    Hello maliming, I am changing my question here. I am simple looking for this aspect:

    1. Host should have host related database tables
    2. Tenant should have tenant related database tables
    3. There should be 3rd database tables which can be shared between host and tenant

    when i am looking documentation, i am realizing making identity as separate database will not be a right idea. Please correct me. if i was wrong then help me on below point.

    Now when i look all modules, please help me to identity what all default modules should be on which database i.e. host and tenant

        builder.ConfigurePermissionManagement();//both
        builder.ConfigureSettingManagement();//both
        builder.ConfigureBackgroundJobs(); //both
        builder.ConfigureAuditLogging(); //both
        builder.ConfigureIdentityPro(); //both
        builder.ConfigureIdentityServer(); //both, 
        builder.ConfigureFeatureManagement(); //host
        builder.ConfigureLanguageManagement(); //both
        builder.ConfigureSaas(); //host
        builder.ConfigureTextTemplateManagement(); //both
        builder.ConfigureBlobStoring(); //both
        builder.ConfigureCmsKit(); //both
        builder.ConfigureCmsKitPro(); //both
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    There should be 3rd database tables which can be shared between host and tenant

    This is wrong.

    IsTenantOnlyDatabase(): Returns true if you should only create tenant-related tables, but should not create host-related tables. It is equivalent of checking modelBuilder.GetMultiTenancySide() == MultiTenancySides.Tenant.

    https://docs.abp.io/en/abp/5.1/Entity-Framework-Core-Migrations#separating-host-tenant-database-schemas

  • User Avatar
    0
    shobhit created

    Thanks Maliming.

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