From ce60004537f79465be90db6d5c19b07e1f2ed017 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 10 Sep 2019 15:01:06 +0300 Subject: [PATCH] api & identity resource names are made unique --- .../IdentityServerDbContextModelCreatingExtensions.cs | 4 ++++ ...al.Designer.cs => 20190910115959_Initial.Designer.cs} | 6 +++++- ...190816092925_Initial.cs => 20190910115959_Initial.cs} | 2 ++ .../MyProjectNameMigrationsDbContextModelSnapshot.cs | 4 ++++ ...MyProjectName.EntityFrameworkCore.DbMigrations.csproj | 9 +++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) rename templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/{20190816092925_Initial.Designer.cs => 20190910115959_Initial.Designer.cs} (99%) rename templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/{20190816092925_Initial.cs => 20190910115959_Initial.cs} (99%) 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 1c0adbc6b6..ac33dc9596 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 @@ -173,6 +173,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore s => JsonConvert.DeserializeObject>(s) ); + identityResource.HasAlternateKey(x => x.Name); + identityResource.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired(); }); @@ -200,6 +202,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore s => JsonConvert.DeserializeObject>(s) ); + apiResource.HasAlternateKey(x => x.Name); + 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(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190816092925_Initial.Designer.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190910115959_Initial.Designer.cs similarity index 99% rename from templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190816092925_Initial.Designer.cs rename to templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190910115959_Initial.Designer.cs index 8659b6366e..1fd604d339 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190816092925_Initial.Designer.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190910115959_Initial.Designer.cs @@ -10,7 +10,7 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { [DbContext(typeof(MyProjectNameMigrationsDbContext))] - [Migration("20190816092925_Initial")] + [Migration("20190910115959_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -640,6 +640,8 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); + b.HasAlternateKey("Name"); + b.ToTable("IdentityServerApiResources"); }); @@ -1073,6 +1075,8 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); + b.HasAlternateKey("Name"); + b.ToTable("IdentityServerIdentityResources"); }); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190816092925_Initial.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190910115959_Initial.cs similarity index 99% rename from templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190816092925_Initial.cs rename to templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190910115959_Initial.cs index 187fa6f8a8..cb7e294ea1 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190816092925_Initial.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190910115959_Initial.cs @@ -224,6 +224,7 @@ namespace MyCompanyName.MyProjectName.Migrations constraints: table => { table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); + table.UniqueConstraint("AK_IdentityServerApiResources_Name", x => x.Name); }); migrationBuilder.CreateTable( @@ -309,6 +310,7 @@ namespace MyCompanyName.MyProjectName.Migrations constraints: table => { table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); + table.UniqueConstraint("AK_IdentityServerIdentityResources_Name", x => x.Name); }); migrationBuilder.CreateTable( diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs index 67f73bd749..b7b82e62a1 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs @@ -638,6 +638,8 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); + b.HasAlternateKey("Name"); + b.ToTable("IdentityServerApiResources"); }); @@ -1071,6 +1073,8 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); + b.HasAlternateKey("Name"); + b.ToTable("IdentityServerIdentityResources"); }); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj index 02317d4ea4..32d39bedaa 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj @@ -7,6 +7,11 @@ MyCompanyName.MyProjectName + + + + + @@ -15,4 +20,8 @@ + + + +