public static void ConfigureFeatureManagement( this ModelBuilder builder, Action <FeatureManagementModelBuilderConfigurationOptions> optionsAction = null) { Check.NotNull(builder, nameof(builder)); var options = new FeatureManagementModelBuilderConfigurationOptions(); optionsAction?.Invoke(options); /* Configure all entities here. Example: * * builder.Entity<Question>(b => * { * //Configure table & schema name * //b.ToTable(options.TablePrefix + "Questions", options.Schema); * * //Properties * //b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); * * //Configure relations * //b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); * * //Configure indexes * //b.HasIndex(q => q.CreationTime); * }); */ }
public static void ConfigureFeatureManagement( this ModelBuilder builder, Action <FeatureManagementModelBuilderConfigurationOptions> optionsAction = null) { Check.NotNull(builder, nameof(builder)); var options = new FeatureManagementModelBuilderConfigurationOptions( FeatureManagementDbProperties.DbTablePrefix, FeatureManagementDbProperties.DbSchema ); optionsAction?.Invoke(options); builder.Entity <FeatureValue>(b => { b.ToTable(options.TablePrefix + "FeatureValues", options.Schema); b.Property(x => x.Name).HasMaxLength(FeatureValueConsts.MaxNameLength).IsRequired(); b.Property(x => x.Value).HasMaxLength(FeatureValueConsts.MaxValueLength).IsRequired(); b.Property(x => x.ProviderName).HasMaxLength(FeatureValueConsts.MaxProviderNameLength); b.Property(x => x.ProviderKey).HasMaxLength(FeatureValueConsts.MaxProviderKeyLength); b.HasIndex(x => new { x.Name, x.ProviderName, x.ProviderKey }); }); }
public static void ConfigureFeatureManagement( this ModelBuilder builder, Action <FeatureManagementModelBuilderConfigurationOptions> optionsAction = null) { Check.NotNull(builder, nameof(builder)); if (builder.IsTenantOnlyDatabase()) { return; } var options = new FeatureManagementModelBuilderConfigurationOptions( FeatureManagementDbProperties.DbTablePrefix, FeatureManagementDbProperties.DbSchema ); optionsAction?.Invoke(options); builder.Entity <FeatureValue>(b => { b.ToTable(options.TablePrefix + "FeatureValues", options.Schema); b.ConfigureByConvention(); b.Property(x => x.Name).HasMaxLength(FeatureValueConsts.MaxNameLength).IsRequired(); b.Property(x => x.Value).HasMaxLength(FeatureValueConsts.MaxValueLength).IsRequired(); b.Property(x => x.ProviderName).HasMaxLength(FeatureValueConsts.MaxProviderNameLength); b.Property(x => x.ProviderKey).HasMaxLength(FeatureValueConsts.MaxProviderKeyLength); b.HasIndex(x => new { x.Name, x.ProviderName, x.ProviderKey }); b.ApplyObjectExtensionMappings(); }); builder.TryConfigureObjectExtensions <FeatureManagementDbContext>(); }