Browse Source

CmsKit - Add GlobalFeature check to configuration of ModelBuilder

pull/7024/head
enisn 6 years ago
parent
commit
f48409be6c
  1. 53
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

53
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

@ -41,8 +41,8 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ConfigureByConvention();
b.ConfigureAbpUser();
b.HasIndex(x => new {x.TenantId, x.UserName});
b.HasIndex(x => new {x.TenantId, x.Email});
b.HasIndex(x => new { x.TenantId, x.UserName });
b.HasIndex(x => new { x.TenantId, x.Email });
});
}
@ -93,59 +93,62 @@ namespace Volo.CmsKit.EntityFrameworkCore
r.Property(x => x.EntityType).IsRequired().HasMaxLength(RatingConsts.MaxEntityTypeLength);
r.Property(x => x.EntityId).IsRequired().HasMaxLength(RatingConsts.MaxEntityIdLength);
r.HasIndex(x => new {x.TenantId, x.EntityType, x.EntityId, x.CreatorId});
r.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId, x.CreatorId });
});
}
builder.Entity<Content>(b =>
{
b.ToTable(options.TablePrefix + "Contents", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength);
b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength);
b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength);
b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId });
});
builder.Entity<Tag>(b =>
if (GlobalFeatureManager.Instance.IsEnabled<TagsFeature>())
{
b.ToTable(options.TablePrefix + "Tags", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength);
b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength);
b.HasIndex(x => new { x.TenantId, x.Name });
});
builder.Entity<Tag>(b =>
{
b.ToTable(options.TablePrefix + "Tags", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength);
b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength);
b.HasIndex(x => new { x.TenantId, x.Name });
});
}
builder.Entity<EntityTag>(b =>
{
b.ToTable(options.TablePrefix + "EntityTags", options.Schema);
b.ConfigureByConvention();
b.HasKey(x => new { x.EntityId, x.TagId });
b.Property(x => x.EntityId).IsRequired();
b.Property(x => x.TagId).IsRequired();
b.HasIndex(x => new { x.TenantId, x.EntityId, x.TagId });
});
builder.Entity<Page>(b =>
{
b.ToTable(options.TablePrefix + "Pages", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength);
b.Property(x => x.Url).IsRequired().HasMaxLength(PageConsts.MaxUrlLength);
b.Property(x => x.Description).HasMaxLength(PageConsts.MaxDescriptionLength);
b.HasIndex(x => new { x.TenantId, x.Url });
});
}

Loading…
Cancel
Save