Open Closed

DbMigrator fails silently after migration to abp commercial #7398


User avatar
0
O_SAG created
  • ABP Framework version: v8.0
  • UI Type: Angular
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: no error
  • Steps to reproduce the issue: unsure

Following up on the last question with the migration to commercial: https://support.abp.io/QA/Questions/7345/Dependency-Injection-Exception-after-migration-from-open-source-to-commercial#answer-3a133714-a55b-6664-d7c0-1370c2b2102b

We now noticed that the DbMigrator does not work at all. When executed with dotnet run, there is no log output, no console output and nothing changes in the db.

I did confirm that it worked before, so it must be because of the changes while migrating to abp commercial.

dotnet -d run simply gives:

Telemetry is: Enabled
...\aspnet-core\src\Common\cap.DbMigrator\bin\Debug\net8.0\cap.DbMigrator.exe  wird ausgeführt.
Prozess-ID: 42116

and nothing more.

I don't even know how to debug this since there is no error message. It simply does nothing.

The only thing I could find where dotnet has the same behaviour is this: https://github.com/dotnet/sdk/issues/36819 where the error was in a false appsettings.json. During migration, I did fill the previously empty appsettings.secrets.json with the AbpLicenceCode. Maybe there is an issue with that?

Has anyone ever encountered this and can help?


7 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You can try configure the appsettings.secrets.json

  • User Avatar
    0
    O_SAG created

    You can try configure the appsettings.secrets.json

    Thanks, but this is already implemented like you suggested. I'm not sure appsettings.secrets.json is even the problem :(

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Is this still not working? Could you share a simple example project with me? I will check it. shiwei.liang@volosoft.com

  • User Avatar
    0
    O_SAG created

    Further investigations:

    • dotnet build works without issues
    • The error occures in await application.InitializeAsync(); in StartAsync() in DbMigratorHostedService.cs:
    public async Task StartAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("Starting DbMigrator...");
            using var application = await AbpApplicationFactory.CreateAsync<CapDbMigratorModule>(options =>
            {
                options.Services.ReplaceConfiguration(_configuration);
                options.Services.ReplaceConfiguration(BuildConfiguration());
                options.UseAutofac();
                options.Services.AddLogging(c => c.AddSerilog());
                options.AddDataMigrationEnvironment();
            });
            
            Console.WriteLine("0");
            
            await application.InitializeAsync();
            
            Console.WriteLine("1");
    
            await application
                .ServiceProvider
                .GetRequiredService<CapDbMigrationService>()
                .MigrateAsync();
            
            Console.WriteLine("2");
    
            await application.ShutdownAsync();
            
            Console.WriteLine("3");
    
            _hostApplicationLifetime.StopApplication();
            Console.WriteLine("DbMigrator finished.");
        }
    

    It does not reach Console.WriteLine("1");. Now it comes to abp internals of which I have no idea. Maybe this helps?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I think this is related to the AbpLicenceCode

  • User Avatar
    0
    O_SAG created

    You were right. I solved it. AbpLicenceCode in appsettings.secrets.json was not read in, because we added custom code to read in appsettings from different environments, which did not read in the secrets file since we did not need it before.

    Now that the DbMigrator has the Licence Code, it does not crash anymore.

    Maybe a suggestion: There should be an error message thrown, its really confusing and inconvenient if the program silently crashes.

    Thank you for your help @liangshiwei

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Okay, great to hear that the problem was solved.

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