Starts in:
1 DAY
23 HRS
43 MIN
34 SEC
Starts in:
1 D
23 H
43 M
34 S
Open Closed

If you are using Entity Framework Core, do not forget to add a new migration and update your database. #2556


User avatar
0
zhongfang created
  • ABP Framework version: v5.1.3
  • UI type: Blazor (Server Side
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
  • Add CmsKit module with ABP Suite 5.1.3
  • Run command
PS D:\abp-change\saas-admin\src\Yee.Change.Id5.EntityFrameworkCore> dotnet ef migrations add AddTables_CmsKitPro --context Id5DbContext
Build started...
Build succeeded.
Done. To undo this action, use 'ef migrations remove'
PS D:\abp-change\saas-admin\src\Yee.Change.Id5.EntityFrameworkCore> dotnet ef database update --context Id5DbContext
Build started...
Build succeeded.
Applying migration '20220209034057_Added_Pro_Module_52534'.
Applying migration '20220209035638_AddTables_CmsKitPro'.
Done.
  • Can not find CmsKit tables in database
public partial class AddTables_CmsKitPro : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {

        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {

        }
    }
public abstract class Id5DbContextBase<TDbContext> : AbpDbContext<TDbContext>
        where TDbContext : DbContext
    {
        public Id5DbContextBase(DbContextOptions<TDbContext> options)
            : base(options)
        {

        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            /* Include modules to your migration db context */

            builder.ConfigurePermissionManagement();
            builder.ConfigureSettingManagement();
            builder.ConfigureBackgroundJobs();
            builder.ConfigureAuditLogging();
            builder.ConfigureIdentityPro();
            builder.ConfigureIdentityServer();
            builder.ConfigureFeatureManagement();
            builder.ConfigureLanguageManagement();
            builder.ConfigureSaas();
            builder.ConfigureTextTemplateManagement();
            builder.ConfigureBlobStoring();

            /* Configure your own tables/entities inside here */

            //builder.Entity<YourEntity>(b =>
            //{
            //    b.ToTable(Id5Consts.DbTablePrefix + "YourEntities", Id5Consts.DbSchema);
            //    b.ConfigureByConvention(); //auto configure for the base class props
            //    //...
            //});

            //if (builder.IsHostDatabase())
            //{
            //    /* Tip: Configure mappings like that for the entities only available in the host side,
            //     * but should not be in the tenant databases. */
            //}
            builder.ConfigureCmsKitPro();
            builder.ConfigureCmsKit();
        }
    }
[DependsOn(
        typeof(Id5DomainModule),
        typeof(AbpIdentityProEntityFrameworkCoreModule),
        typeof(AbpIdentityServerEntityFrameworkCoreModule),
        typeof(AbpPermissionManagementEntityFrameworkCoreModule),
        typeof(AbpSettingManagementEntityFrameworkCoreModule),
        typeof(AbpEntityFrameworkCoreSqlServerModule),
        typeof(AbpBackgroundJobsEntityFrameworkCoreModule),
        typeof(AbpAuditLoggingEntityFrameworkCoreModule),
        typeof(AbpFeatureManagementEntityFrameworkCoreModule),
        typeof(LanguageManagementEntityFrameworkCoreModule),
        typeof(SaasEntityFrameworkCoreModule),
        typeof(TextTemplateManagementEntityFrameworkCoreModule),
        typeof(BlobStoringDatabaseEntityFrameworkCoreModule)
    )]
    [DependsOn(typeof(CmsKitProEntityFrameworkCoreModule))]
    public class Id5EntityFrameworkCoreModule : AbpModule
    {
        public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            Id5EfCoreEntityExtensionMappings.Configure();
        }

        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAbpDbContext<Id5DbContext>(options =>
            {
                /* Remove "includeAllEntities: true" to create
                 * default repositories only for aggregate roots */
                options.AddDefaultRepositories(includeAllEntities: true);
            });

            context.Services.AddAbpDbContext<Id5TenantDbContext>(options =>
            {
                /* Remove "includeAllEntities: true" to create
                 * default repositories only for aggregate roots */
                options.AddDefaultRepositories(includeAllEntities: true);
            });

            Configure<AbpDbContextOptions>(options =>
            {
                /* The main point to change your DBMS.
                 * See also Id5DbContextFactoryBase for EF Core tooling. */
                options.UseSqlServer();
            });
        }
    }

4 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi @zhongfang

    Have you completed all installation steps of CmsKit?

    I think enabling Global Features will solve the problem:

    GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit =>
    {
        cmsKit.EnableAll();
    });
    
    GlobalFeatureManager.Instance.Modules.CmsKitPro(cmsKitPro =>
    {
        cmsKitPro.EnableAll();
    });
    

    Can you try creating migration after enabling global features?

  • User Avatar
    0
    zhongfang created

    Oh, I add above global features. Then I rebuild the solutions. Run ef migrations add again. still got nothing.

    [DependsOn(typeof(CmsKitProDomainSharedModule))]
        public class Id5DomainSharedModule : AbpModule
        {
            public override void PreConfigureServices(ServiceConfigurationContext context)
            {
                Id5GlobalFeatureConfigurator.Configure();
                Id5ModuleExtensionConfigurator.Configure();
            }
    
            public override void ConfigureServices(ServiceConfigurationContext context)
            {
                Configure<AbpVirtualFileSystemOptions>(options =>
                {
                    options.FileSets.AddEmbedded<Id5DomainSharedModule>();
                });
    
                Configure<AbpLocalizationOptions>(options =>
                {
                    options.Resources
                        .Add<Id5Resource>("en")
                        .AddBaseTypes(typeof(AbpValidationResource))
                        .AddVirtualJson("/Localization/Id5");
    
                    options.DefaultResourceType = typeof(Id5Resource);
                });
    
                Configure<AbpExceptionLocalizationOptions>(options =>
                {
                    options.MapCodeNamespace("Id5", typeof(Id5Resource));
                }); 
                
                GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit =>
                {
                    cmsKit.EnableAll();
                });
    
                GlobalFeatureManager.Instance.Modules.CmsKitPro(cmsKitPro =>
                {
                    cmsKitPro.EnableAll();
                });
            }
    
    public partial class AddTables_CmsKitPro_Enabled : Migration
        {
            protected override void Up(MigrationBuilder migrationBuilder)
            {
    
            }
    
            protected override void Down(MigrationBuilder migrationBuilder)
            {
    
            }
        }
    
  • User Avatar
    0
    zhongfang created

    Any progress?

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi

    As CmsKit Pro Documentation says, you have to do it in GlobalFeatureConfigurator class in your Domain.Shared project. If not, please do it in PreConfigureServices method.

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