0
muleso created
i want to add AbpOrganizationUnitRoles table to a custom table, advice
using Abp.Application.Editions;
using Abp.Application.Features;
using Abp.Auditing;
using Abp.Authorization;
using Abp.Authorization.Roles;
using Abp.Authorization.Users;
using Abp.BackgroundJobs;
using Abp.Configuration;
using Abp.Localization;
using Abp.MultiTenancy;
using Abp.Notifications;
using Abp.Organizations;
using Microsoft.EntityFrameworkCore;
namespace Abp.Zero.EntityFrameworkCore
{
/// <summary>
/// Extension methods for <see cref="DbModelBuilder"/>.
/// </summary>
public static class AbpZeroDbModelBuilderExtensions
{
/// <summary>
/// Changes prefix for ABP tables (which is "Abp" by default).
/// Can be null/empty string to clear the prefix.
/// </summary>
/// <typeparam name="TTenant">The type of the tenant entity.</typeparam>
/// <typeparam name="TRole">The type of the role entity.</typeparam>
/// <typeparam name="TUser">The type of the user entity.</typeparam>
/// <param name="modelBuilder">Model builder.</param>
/// <param name="prefix">Table prefix, or null to clear prefix.</param>
public static void ChangeAbpTablePrefix0<TTenant, TRole, TUser>(this ModelBuilder modelBuilder, string prefix, string schemaName = null)
where TTenant : AbpTenant<TUser>
where TRole : AbpRole<TUser>
where TUser : AbpUser<TUser>
{
prefix = prefix ?? "";
SetTableName<AuditLog>(modelBuilder, prefix + "30", schemaName);
SetTableName<BackgroundJobInfo>(modelBuilder, prefix + "31", schemaName);
SetTableName<Edition>(modelBuilder, prefix + "32", schemaName);
SetTableName<FeatureSetting>(modelBuilder, prefix + "33", schemaName);
SetTableName<TenantFeatureSetting>(modelBuilder, prefix + "34", schemaName);
SetTableName<EditionFeatureSetting>(modelBuilder, prefix + "35", schemaName);
SetTableName<ApplicationLanguage>(modelBuilder, prefix + "36", schemaName);
SetTableName<ApplicationLanguageText>(modelBuilder, prefix + "37", schemaName);
SetTableName<NotificationInfo>(modelBuilder, prefix + "38", schemaName);
SetTableName<NotificationSubscriptionInfo>(modelBuilder, prefix + "39", schemaName);
SetTableName<OrganizationUnit>(modelBuilder, prefix + "40", schemaName);
SetTableName<PermissionSetting>(modelBuilder, prefix + "41", schemaName);
SetTableName<RolePermissionSetting>(modelBuilder, prefix + "42", schemaName);
SetTableName<UserPermissionSetting>(modelBuilder, prefix + "43", schemaName);
SetTableName<TRole>(modelBuilder, prefix + "44", schemaName);
SetTableName<Setting>(modelBuilder, prefix + "45", schemaName);
SetTableName<TTenant>(modelBuilder, prefix + "46", schemaName);
SetTableName<UserLogin>(modelBuilder, prefix + "47", schemaName);
SetTableName<UserLoginAttempt>(modelBuilder, prefix + "48", schemaName);
SetTableName<TenantNotificationInfo>(modelBuilder, prefix + "49", schemaName);
SetTableName<UserNotificationInfo>(modelBuilder, prefix + "50", schemaName);
SetTableName<UserOrganizationUnit>(modelBuilder, prefix + "51", schemaName);
SetTableName<UserRole>(modelBuilder, prefix + "52", schemaName);
SetTableName<TUser>(modelBuilder, prefix + "53", schemaName);
SetTableName<UserAccount>(modelBuilder, prefix + "54", schemaName);
SetTableName<UserClaim>(modelBuilder, prefix + "55", schemaName);
//SetTableName<>(modelBuilder, prefix + "55", schemaName);
}
private static void SetTableName<TEntity>(ModelBuilder modelBuilder, string tableName, string schemaName)
where TEntity : class
{
if (schemaName == null)
{
modelBuilder.Entity<TEntity>().ToTable(tableName);
}
else
{
modelBuilder.Entity<TEntity>().ToTable(tableName, schemaName);
}
}
}
}
4 Answer(s)
-
0
Please share your DbContext code.
-
0
Hello,
I think, you didn't get my question, i want to add a new table AbpOrganizationUnitRoles to above class, this new table you added in the latest version, it wasnt there before
-
0
-
0