diff --git a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsDbContextModelBuilderExtensions.cs b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsDbContextModelBuilderExtensions.cs index 64a85db140..379ca8792d 100644 --- a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsDbContextModelBuilderExtensions.cs +++ b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsDbContextModelBuilderExtensions.cs @@ -63,6 +63,8 @@ namespace Volo.Docs.EntityFrameworkCore { b.ToTable(options.TablePrefix + "DocumentContributors", options.Schema); + b.ConfigureByConvention(); + b.HasKey(x => new { x.DocumentId, x.Username }); }); } diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs index eb8b18ee0a..d854f89448 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs @@ -1,5 +1,6 @@ using System; using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Modeling; namespace Volo.Abp.FeatureManagement.EntityFrameworkCore { @@ -22,6 +23,8 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore { 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); diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs index 9f65e4e419..277084e13d 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs @@ -28,264 +28,292 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore optionsAction?.Invoke(options); - builder.Entity(client => + builder.Entity(b => { - client.ToTable(options.TablePrefix + "Clients", options.Schema); - - client.ConfigureFullAuditedAggregateRoot(); - - client.Property(x => x.ClientId).HasMaxLength(ClientConsts.ClientIdMaxLength).IsRequired(); - client.Property(x => x.ProtocolType).HasMaxLength(ClientConsts.ProtocolTypeMaxLength).IsRequired(); - client.Property(x => x.ClientName).HasMaxLength(ClientConsts.ClientNameMaxLength); - client.Property(x => x.ClientUri).HasMaxLength(ClientConsts.ClientUriMaxLength); - client.Property(x => x.LogoUri).HasMaxLength(ClientConsts.LogoUriMaxLength); - client.Property(x => x.Description).HasMaxLength(ClientConsts.DescriptionMaxLength); - client.Property(x => x.FrontChannelLogoutUri).HasMaxLength(ClientConsts.FrontChannelLogoutUriMaxLength); - client.Property(x => x.BackChannelLogoutUri).HasMaxLength(ClientConsts.BackChannelLogoutUriMaxLength); - client.Property(x => x.ClientClaimsPrefix).HasMaxLength(ClientConsts.ClientClaimsPrefixMaxLength); - client.Property(x => x.PairWiseSubjectSalt).HasMaxLength(ClientConsts.PairWiseSubjectSaltMaxLength); - client.Property(x => x.UserCodeType).HasMaxLength(ClientConsts.UserCodeTypeMaxLength); - - client.HasMany(x => x.AllowedScopes).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.ClientSecrets).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.AllowedGrantTypes).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.AllowedCorsOrigins).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.RedirectUris).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.PostLogoutRedirectUris).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.IdentityProviderRestrictions).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.Claims).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - client.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); - - client.HasIndex(x => x.ClientId); + b.ToTable(options.TablePrefix + "Clients", options.Schema); + + b.ConfigureByConvention(); + + b.Property(x => x.ClientId).HasMaxLength(ClientConsts.ClientIdMaxLength).IsRequired(); + b.Property(x => x.ProtocolType).HasMaxLength(ClientConsts.ProtocolTypeMaxLength).IsRequired(); + b.Property(x => x.ClientName).HasMaxLength(ClientConsts.ClientNameMaxLength); + b.Property(x => x.ClientUri).HasMaxLength(ClientConsts.ClientUriMaxLength); + b.Property(x => x.LogoUri).HasMaxLength(ClientConsts.LogoUriMaxLength); + b.Property(x => x.Description).HasMaxLength(ClientConsts.DescriptionMaxLength); + b.Property(x => x.FrontChannelLogoutUri).HasMaxLength(ClientConsts.FrontChannelLogoutUriMaxLength); + b.Property(x => x.BackChannelLogoutUri).HasMaxLength(ClientConsts.BackChannelLogoutUriMaxLength); + b.Property(x => x.ClientClaimsPrefix).HasMaxLength(ClientConsts.ClientClaimsPrefixMaxLength); + b.Property(x => x.PairWiseSubjectSalt).HasMaxLength(ClientConsts.PairWiseSubjectSaltMaxLength); + b.Property(x => x.UserCodeType).HasMaxLength(ClientConsts.UserCodeTypeMaxLength); + + b.HasMany(x => x.AllowedScopes).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.ClientSecrets).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.AllowedGrantTypes).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.AllowedCorsOrigins).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.RedirectUris).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.PostLogoutRedirectUris).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.IdentityProviderRestrictions).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.Claims).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + + b.HasIndex(x => x.ClientId); }); - builder.Entity(grantType => + builder.Entity(b => { - grantType.ToTable(options.TablePrefix + "ClientGrantTypes", options.Schema); + b.ToTable(options.TablePrefix + "ClientGrantTypes", options.Schema); + + b.ConfigureByConvention(); - grantType.HasKey(x => new { x.ClientId, x.GrantType }); + b.HasKey(x => new { x.ClientId, x.GrantType }); - grantType.Property(x => x.GrantType).HasMaxLength(ClientGrantTypeConsts.GrantTypeMaxLength).IsRequired(); + b.Property(x => x.GrantType).HasMaxLength(ClientGrantTypeConsts.GrantTypeMaxLength).IsRequired(); }); - builder.Entity(redirectUri => + builder.Entity(b => { - redirectUri.ToTable(options.TablePrefix + "ClientRedirectUris", options.Schema); + b.ToTable(options.TablePrefix + "ClientRedirectUris", options.Schema); - redirectUri.HasKey(x => new { x.ClientId, x.RedirectUri }); + b.ConfigureByConvention(); + + b.HasKey(x => new { x.ClientId, x.RedirectUri }); if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql) { - redirectUri.Property(x => x.RedirectUri).HasMaxLength(300).IsRequired(); + b.Property(x => x.RedirectUri).HasMaxLength(300).IsRequired(); } else { - redirectUri.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength).IsRequired(); + b.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength).IsRequired(); } }); - builder.Entity(postLogoutRedirectUri => + builder.Entity(b => { - postLogoutRedirectUri.ToTable(options.TablePrefix + "ClientPostLogoutRedirectUris", options.Schema); + b.ToTable(options.TablePrefix + "ClientPostLogoutRedirectUris", options.Schema); + + b.ConfigureByConvention(); - postLogoutRedirectUri.HasKey(x => new { x.ClientId, x.PostLogoutRedirectUri }); + b.HasKey(x => new { x.ClientId, x.PostLogoutRedirectUri }); if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql) { - postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(300).IsRequired(); + b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(300).IsRequired(); } else { - postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired(); + b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired(); } }); - builder.Entity(scope => + builder.Entity(b => { - scope.ToTable(options.TablePrefix + "ClientScopes", options.Schema); + b.ToTable(options.TablePrefix + "ClientScopes", options.Schema); - scope.HasKey(x => new { x.ClientId, x.Scope }); + b.ConfigureByConvention(); + + b.HasKey(x => new { x.ClientId, x.Scope }); - scope.Property(x => x.Scope).HasMaxLength(ClientScopeConsts.ScopeMaxLength).IsRequired(); + b.Property(x => x.Scope).HasMaxLength(ClientScopeConsts.ScopeMaxLength).IsRequired(); }); - builder.Entity(secret => + builder.Entity(b => { - secret.ToTable(options.TablePrefix + "ClientSecrets", options.Schema); + b.ToTable(options.TablePrefix + "ClientSecrets", options.Schema); - secret.HasKey(x => new { x.ClientId, x.Type, x.Value }); + b.ConfigureByConvention(); - secret.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired(); + b.HasKey(x => new { x.ClientId, x.Type, x.Value }); + + b.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired(); if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql) { - secret.Property(x => x.Value).HasMaxLength(300).IsRequired(); + b.Property(x => x.Value).HasMaxLength(300).IsRequired(); } else { - secret.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired(); + b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired(); } - secret.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength); + b.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength); }); - builder.Entity(claim => + builder.Entity(b => { - claim.ToTable(options.TablePrefix + "ClientClaims", options.Schema); + b.ToTable(options.TablePrefix + "ClientClaims", options.Schema); - claim.HasKey(x => new { x.ClientId, x.Type, x.Value }); + b.ConfigureByConvention(); - claim.Property(x => x.Type).HasMaxLength(ClientClaimConsts.TypeMaxLength).IsRequired(); - claim.Property(x => x.Value).HasMaxLength(ClientClaimConsts.ValueMaxLength).IsRequired(); + b.HasKey(x => new { x.ClientId, x.Type, x.Value }); + + b.Property(x => x.Type).HasMaxLength(ClientClaimConsts.TypeMaxLength).IsRequired(); + b.Property(x => x.Value).HasMaxLength(ClientClaimConsts.ValueMaxLength).IsRequired(); }); - builder.Entity(idPRestriction => + builder.Entity(b => { - idPRestriction.ToTable(options.TablePrefix + "ClientIdPRestrictions", options.Schema); + b.ToTable(options.TablePrefix + "ClientIdPRestrictions", options.Schema); + + b.ConfigureByConvention(); - idPRestriction.HasKey(x => new { x.ClientId, x.Provider }); + b.HasKey(x => new { x.ClientId, x.Provider }); - idPRestriction.Property(x => x.Provider).HasMaxLength(ClientIdPRestrictionConsts.ProviderMaxLength).IsRequired(); + b.Property(x => x.Provider).HasMaxLength(ClientIdPRestrictionConsts.ProviderMaxLength).IsRequired(); }); - builder.Entity(corsOrigin => + builder.Entity(b => { - corsOrigin.ToTable(options.TablePrefix + "ClientCorsOrigins", options.Schema); + b.ToTable(options.TablePrefix + "ClientCorsOrigins", options.Schema); - corsOrigin.HasKey(x => new { x.ClientId, x.Origin }); + b.ConfigureByConvention(); - corsOrigin.Property(x => x.Origin).HasMaxLength(ClientCorsOriginConsts.OriginMaxLength).IsRequired(); + b.HasKey(x => new { x.ClientId, x.Origin }); + + b.Property(x => x.Origin).HasMaxLength(ClientCorsOriginConsts.OriginMaxLength).IsRequired(); }); - builder.Entity(property => + builder.Entity(b => { - property.ToTable(options.TablePrefix + "ClientProperties", options.Schema); + b.ToTable(options.TablePrefix + "ClientProperties", options.Schema); + + b.ConfigureByConvention(); - property.HasKey(x => new { x.ClientId, x.Key }); + b.HasKey(x => new { x.ClientId, x.Key }); - property.Property(x => x.Key).HasMaxLength(ClientPropertyConsts.KeyMaxLength).IsRequired(); - property.Property(x => x.Value).HasMaxLength(ClientPropertyConsts.ValueMaxLength).IsRequired(); + b.Property(x => x.Key).HasMaxLength(ClientPropertyConsts.KeyMaxLength).IsRequired(); + b.Property(x => x.Value).HasMaxLength(ClientPropertyConsts.ValueMaxLength).IsRequired(); }); - builder.Entity(grant => + builder.Entity(b => { - grant.ToTable(options.TablePrefix + "PersistedGrants", options.Schema); + b.ToTable(options.TablePrefix + "PersistedGrants", options.Schema); - grant.ConfigureExtraProperties(); + b.ConfigureByConvention(); - grant.Property(x => x.Key).HasMaxLength(PersistedGrantConsts.KeyMaxLength).ValueGeneratedNever(); - grant.Property(x => x.Type).HasMaxLength(PersistedGrantConsts.TypeMaxLength).IsRequired(); - grant.Property(x => x.SubjectId).HasMaxLength(PersistedGrantConsts.SubjectIdMaxLength); - grant.Property(x => x.ClientId).HasMaxLength(PersistedGrantConsts.ClientIdMaxLength).IsRequired(); - grant.Property(x => x.CreationTime).IsRequired(); + b.Property(x => x.Key).HasMaxLength(PersistedGrantConsts.KeyMaxLength).ValueGeneratedNever(); + b.Property(x => x.Type).HasMaxLength(PersistedGrantConsts.TypeMaxLength).IsRequired(); + b.Property(x => x.SubjectId).HasMaxLength(PersistedGrantConsts.SubjectIdMaxLength); + b.Property(x => x.ClientId).HasMaxLength(PersistedGrantConsts.ClientIdMaxLength).IsRequired(); + b.Property(x => x.CreationTime).IsRequired(); if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql) { - grant.Property(x => x.Data).HasMaxLength(10000).IsRequired(); + b.Property(x => x.Data).HasMaxLength(10000).IsRequired(); } else { - grant.Property(x => x.Data).HasMaxLength(PersistedGrantConsts.DataMaxLength).IsRequired(); + b.Property(x => x.Data).HasMaxLength(PersistedGrantConsts.DataMaxLength).IsRequired(); } - grant.HasKey(x => x.Key); //TODO: What about Id!!! + b.HasKey(x => x.Key); //TODO: What about Id!!! - grant.HasIndex(x => new { x.SubjectId, x.ClientId, x.Type }); - grant.HasIndex(x => x.Expiration); + b.HasIndex(x => new { x.SubjectId, x.ClientId, x.Type }); + b.HasIndex(x => x.Expiration); }); - builder.Entity(identityResource => + builder.Entity(b => { - identityResource.ToTable(options.TablePrefix + "IdentityResources", options.Schema); + b.ToTable(options.TablePrefix + "IdentityResources", options.Schema); - identityResource.ConfigureFullAuditedAggregateRoot(); + b.ConfigureByConvention(); - identityResource.Property(x => x.Name).HasMaxLength(IdentityResourceConsts.NameMaxLength).IsRequired(); - identityResource.Property(x => x.DisplayName).HasMaxLength(IdentityResourceConsts.DisplayNameMaxLength); - identityResource.Property(x => x.Description).HasMaxLength(IdentityResourceConsts.DescriptionMaxLength); - identityResource.Property(x => x.Properties) + b.Property(x => x.Name).HasMaxLength(IdentityResourceConsts.NameMaxLength).IsRequired(); + b.Property(x => x.DisplayName).HasMaxLength(IdentityResourceConsts.DisplayNameMaxLength); + b.Property(x => x.Description).HasMaxLength(IdentityResourceConsts.DescriptionMaxLength); + b.Property(x => x.Properties) .HasConversion(new AbpJsonValueConverter>()) .Metadata.SetValueComparer(new AbpDictionaryValueComparer()); - identityResource.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired(); + b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired(); }); - builder.Entity(claim => + builder.Entity(b => { - claim.ToTable(options.TablePrefix + "IdentityClaims", options.Schema); + b.ToTable(options.TablePrefix + "IdentityClaims", options.Schema); + + b.ConfigureByConvention(); - claim.HasKey(x => new { x.IdentityResourceId, x.Type }); + b.HasKey(x => new { x.IdentityResourceId, x.Type }); - claim.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); + b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); }); - builder.Entity(apiResource => + builder.Entity(b => { - apiResource.ToTable(options.TablePrefix + "ApiResources", options.Schema); + b.ToTable(options.TablePrefix + "ApiResources", options.Schema); - apiResource.ConfigureFullAuditedAggregateRoot(); + b.ConfigureByConvention(); - apiResource.Property(x => x.Name).HasMaxLength(ApiResourceConsts.NameMaxLength).IsRequired(); - apiResource.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength); - apiResource.Property(x => x.Description).HasMaxLength(ApiResourceConsts.DescriptionMaxLength); - apiResource.Property(x => x.Properties) + b.Property(x => x.Name).HasMaxLength(ApiResourceConsts.NameMaxLength).IsRequired(); + b.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength); + b.Property(x => x.Description).HasMaxLength(ApiResourceConsts.DescriptionMaxLength); + b.Property(x => x.Properties) .HasConversion(new AbpJsonValueConverter>()) .Metadata.SetValueComparer(new AbpDictionaryValueComparer()); - apiResource.HasMany(x => x.Secrets).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); - apiResource.HasMany(x => x.Scopes).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); - apiResource.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); + b.HasMany(x => x.Secrets).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); + b.HasMany(x => x.Scopes).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); + b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); }); - builder.Entity(apiSecret => + builder.Entity(b => { - apiSecret.ToTable(options.TablePrefix + "ApiSecrets", options.Schema); + b.ToTable(options.TablePrefix + "ApiSecrets", options.Schema); - apiSecret.HasKey(x => new { x.ApiResourceId, x.Type, x.Value }); + b.ConfigureByConvention(); + + b.HasKey(x => new { x.ApiResourceId, x.Type, x.Value }); - apiSecret.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired(); - apiSecret.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength); + b.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired(); + b.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength); if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql) { - apiSecret.Property(x => x.Value).HasMaxLength(300).IsRequired(); + b.Property(x => x.Value).HasMaxLength(300).IsRequired(); } else { - apiSecret.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired(); + b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired(); } }); - builder.Entity(apiClaim => + builder.Entity(b => { - apiClaim.ToTable(options.TablePrefix + "ApiClaims", options.Schema); + b.ToTable(options.TablePrefix + "ApiClaims", options.Schema); + + b.ConfigureByConvention(); - apiClaim.HasKey(x => new { x.ApiResourceId, x.Type }); + b.HasKey(x => new { x.ApiResourceId, x.Type }); - apiClaim.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); + b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); }); - builder.Entity(apiScope => + builder.Entity(b => { - apiScope.ToTable(options.TablePrefix + "ApiScopes", options.Schema); + b.ToTable(options.TablePrefix + "ApiScopes", options.Schema); - apiScope.HasKey(x => new { x.ApiResourceId, x.Name }); + b.ConfigureByConvention(); + + b.HasKey(x => new { x.ApiResourceId, x.Name }); - apiScope.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); - apiScope.Property(x => x.DisplayName).HasMaxLength(ApiScopeConsts.DisplayNameMaxLength); - apiScope.Property(x => x.Description).HasMaxLength(ApiScopeConsts.DescriptionMaxLength); + b.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); + b.Property(x => x.DisplayName).HasMaxLength(ApiScopeConsts.DisplayNameMaxLength); + b.Property(x => x.Description).HasMaxLength(ApiScopeConsts.DescriptionMaxLength); - apiScope.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => new { x.ApiResourceId, x.Name }).IsRequired(); + b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => new { x.ApiResourceId, x.Name }).IsRequired(); }); - builder.Entity(apiScopeClaim => + builder.Entity(b => { - apiScopeClaim.ToTable(options.TablePrefix + "ApiScopeClaims", options.Schema); + b.ToTable(options.TablePrefix + "ApiScopeClaims", options.Schema); + + b.ConfigureByConvention(); - apiScopeClaim.HasKey(x => new { x.ApiResourceId, x.Name, x.Type }); + b.HasKey(x => new { x.ApiResourceId, x.Name, x.Type }); - apiScopeClaim.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); - apiScopeClaim.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); + b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); + b.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); }); builder.Entity(b => diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/AbpPermissionManagementDbContextModelBuilderExtensions.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/AbpPermissionManagementDbContextModelBuilderExtensions.cs index 6fefa69c8f..419389568a 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/AbpPermissionManagementDbContextModelBuilderExtensions.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/AbpPermissionManagementDbContextModelBuilderExtensions.cs @@ -1,6 +1,7 @@ using System; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Modeling; namespace Volo.Abp.PermissionManagement.EntityFrameworkCore { @@ -23,6 +24,8 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore { b.ToTable(options.TablePrefix + "PermissionGrants", options.Schema); + b.ConfigureByConvention(); + b.Property(x => x.Name).HasMaxLength(PermissionGrantConsts.MaxNameLength).IsRequired(); b.Property(x => x.ProviderName).HasMaxLength(PermissionGrantConsts.MaxProviderNameLength).IsRequired(); b.Property(x => x.ProviderKey).HasMaxLength(PermissionGrantConsts.MaxProviderKeyLength).IsRequired(); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs index d0de79aa7e..715d7abfd0 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs @@ -38,6 +38,8 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore { 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); diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementDbContextModelCreatingExtensions.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementDbContextModelCreatingExtensions.cs index 2cb7964041..03858df202 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementDbContextModelCreatingExtensions.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementDbContextModelCreatingExtensions.cs @@ -24,7 +24,7 @@ namespace Volo.Abp.TenantManagement.EntityFrameworkCore { b.ToTable(options.TablePrefix + "Tenants", options.Schema); - b.ConfigureFullAuditedAggregateRoot(); + b.ConfigureByConvention(); b.Property(t => t.Name).IsRequired().HasMaxLength(TenantConsts.MaxNameLength); @@ -37,6 +37,8 @@ namespace Volo.Abp.TenantManagement.EntityFrameworkCore { b.ToTable(options.TablePrefix + "TenantConnectionStrings", options.Schema); + b.ConfigureByConvention(); + b.HasKey(x => new { x.TenantId, x.Name }); b.Property(cs => cs.Name).IsRequired().HasMaxLength(TenantConnectionStringConsts.MaxNameLength);