Example #1
0
        //TODO: Instead of getting parameters, get a action of SettingManagementModelBuilderConfigurationOptions like other modules
        public static void ConfigureSettingManagement(
            [NotNull] this ModelBuilder builder,
            [CanBeNull] Action <SettingManagementModelBuilderConfigurationOptions> optionsAction = null)
        {
            Check.NotNull(builder, nameof(builder));

            var options = new SettingManagementModelBuilderConfigurationOptions(
                AbpSettingManagementDbProperties.DbTablePrefix,
                AbpSettingManagementDbProperties.DbSchema
                );

            optionsAction?.Invoke(options);

            builder.Entity <Setting>(b =>
            {
                b.ToTable(options.TablePrefix + "Settings", options.Schema);

                b.ConfigureByConvention();

                b.Property(x => x.Name).HasMaxLength(SettingConsts.MaxNameLength).IsRequired();
                b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLength).IsRequired();
                b.Property(x => x.ProviderName).HasMaxLength(SettingConsts.MaxProviderNameLength);
                b.Property(x => x.ProviderKey).HasMaxLength(SettingConsts.MaxProviderKeyLength);

                b.HasIndex(x => new { x.Name, x.ProviderName, x.ProviderKey });
            });
        }
Example #2
0
        //TODO: Instead of getting parameters, get a action of SettingManagementModelBuilderConfigurationOptions like other modules
        public static void ConfigureSettingManagement(
            [NotNull] this ModelBuilder builder,
            [CanBeNull] Action <SettingManagementModelBuilderConfigurationOptions> optionsAction = null)
        {
            Check.NotNull(builder, nameof(builder));

            if (builder.IsTenantOnlyDatabase())
            {
                return;
            }

            var options = new SettingManagementModelBuilderConfigurationOptions(
                AbpSettingManagementDbProperties.DbTablePrefix,
                AbpSettingManagementDbProperties.DbSchema
                );

            optionsAction?.Invoke(options);

            builder.Entity <Setting>(b =>
            {
                b.ToTable(options.TablePrefix + "Settings", options.Schema);

                b.ConfigureByConvention();

                b.Property(x => x.Name).HasMaxLength(SettingConsts.MaxNameLength).IsRequired();

                if (builder.IsUsingOracle())
                {
                    SettingConsts.MaxValueLengthValue = 2000;
                }
                b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLengthValue).IsRequired();

                b.Property(x => x.ProviderName).HasMaxLength(SettingConsts.MaxProviderNameLength);
                b.Property(x => x.ProviderKey).HasMaxLength(SettingConsts.MaxProviderKeyLength);

                b.HasIndex(x => new { x.Name, x.ProviderName, x.ProviderKey });

                b.ApplyObjectExtensionMappings();
            });

            builder.TryConfigureObjectExtensions <SettingManagementDbContext>();
        }