Open Closed

Database tables are not created for per-tenant database #2551


User avatar
0
bhasinp created
  • ABP Framework version: v5.1.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Added new entity using Abp Suite and mark it as "MultiTenant". This created the entity with IMultiTenant interface implemented. I then go to Tenant list in SaaS Module and select "Apply database migration" it does update the __EFMigrationsHistory table and adds the new migration but it doesn't create the new table in the tenant database.

What am I missing?


1 Answer(s)
  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    Hi @bhasinp,

    I have reproduced the issue & fixed it for the next patch. Also, your question credit is refunded.

    Problem is that TenantDbContext is not modified during code generation. To fix it manually for now, you have to copy related code from DbContext to TenantDbContext file. Then re-generate migrations.

    example codes to copy:

        public DbSet<Author> Authors { get; set; }
    
            builder.Entity<Author>(b =>
            {
                b.ToTable(MyProjectConsts.DbTablePrefix + "Authors", MyProjectConsts.DbSchema);
                b.ConfigureByConvention();
                b.Property(x => x.TenantId).HasColumnName(nameof(Author.TenantId));
                b.Property(x => x.Name).HasColumnName(nameof(Author.Name));
            });
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11