From 88e7cbabce7e35f930826eccce3a95c5f75ed8c2 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 12 Dec 2018 12:09:55 +0300 Subject: [PATCH 1/8] #246 Implement concurrency control for mongodb too. --- .../Volo/Abp/Domain/Entities/AggregateRoot.cs | 3 + .../Abp/EntityFrameworkCore/AbpDbContext.cs | 25 +++- .../Repositories/MongoDB/MongoDbRepository.cs | 108 +++++++++++++++--- .../MongoDB/Domain/ConcurrencyStamp_Tests.cs | 9 ++ .../TestApp/Testing/ConcurrencyStamp_Tests.cs | 25 +++- 5 files changed, 146 insertions(+), 24 deletions(-) create mode 100644 framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Domain/ConcurrencyStamp_Tests.cs diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs index 3521672445..be222839cd 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs @@ -24,6 +24,7 @@ namespace Volo.Abp.Domain.Entities protected AggregateRoot() { ExtraProperties = new Dictionary(); + ConcurrencyStamp = Guid.NewGuid().ToString("N"); } protected virtual void AddLocalEvent(object eventData) @@ -75,12 +76,14 @@ namespace Volo.Abp.Domain.Entities protected AggregateRoot() { ExtraProperties = new Dictionary(); + ConcurrencyStamp = Guid.NewGuid().ToString("N"); } protected AggregateRoot(TKey id) : base(id) { ExtraProperties = new Dictionary(); + ConcurrencyStamp = Guid.NewGuid().ToString("N"); } protected virtual void AddLocalEvent(object eventData) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs index b5860824cc..530fb45ccf 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs @@ -201,13 +201,14 @@ namespace Volo.Abp.EntityFrameworkCore protected virtual void ApplyAbpConceptsForAddedEntity(EntityEntry entry, EntityChangeReport changeReport) { CheckAndSetId(entry); + SetConcurrencyStampIfNull(entry); SetCreationAuditProperties(entry); changeReport.ChangedEntities.Add(new EntityChangeEntry(entry.Entity, EntityChangeType.Created)); } protected virtual void ApplyAbpConceptsForModifiedEntity(EntityEntry entry, EntityChangeReport changeReport) { - HandleConcurrencyStamp(entry); + UpdateConcurrencyStamp(entry); SetModificationAuditProperties(entry); if (entry.Entity is ISoftDelete && entry.Entity.As().IsDeleted) @@ -224,7 +225,7 @@ namespace Volo.Abp.EntityFrameworkCore protected virtual void ApplyAbpConceptsForDeletedEntity(EntityEntry entry, EntityChangeReport changeReport) { CancelDeletionForSoftDelete(entry); - HandleConcurrencyStamp(entry); + UpdateConcurrencyStamp(entry); SetDeletionAuditProperties(entry); changeReport.ChangedEntities.Add(new EntityChangeEntry(entry.Entity, EntityChangeType.Deleted)); } @@ -252,7 +253,7 @@ namespace Volo.Abp.EntityFrameworkCore } } - protected virtual void HandleConcurrencyStamp(EntityEntry entry) + protected virtual void UpdateConcurrencyStamp(EntityEntry entry) { var entity = entry.Entity as IHasConcurrencyStamp; if (entity == null) @@ -260,7 +261,23 @@ namespace Volo.Abp.EntityFrameworkCore return; } - entity.ConcurrencyStamp = Guid.NewGuid().ToString(); + entity.ConcurrencyStamp = Guid.NewGuid().ToString("N"); + } + + protected virtual void SetConcurrencyStampIfNull(EntityEntry entry) + { + var entity = entry.Entity as IHasConcurrencyStamp; + if (entity == null) + { + return; + } + + if (entity.ConcurrencyStamp != null) + { + return; + } + + entity.ConcurrencyStamp = Guid.NewGuid().ToString("N"); } protected virtual void CancelDeletionForSoftDelete(EntityEntry entry) diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs index f5170210bd..b4877d8246 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs @@ -1,12 +1,13 @@ +using MongoDB.Driver; +using MongoDB.Driver.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; -using MongoDB.Driver; -using MongoDB.Driver.Linq; using Volo.Abp.Auditing; +using Volo.Abp.Data; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EventBus; @@ -97,11 +98,18 @@ namespace Volo.Abp.Domain.Repositories.MongoDB AsyncHelper.RunSync(() => TriggerDomainEventsAsync(entity)); - Collection.ReplaceOne( - CreateEntityFilter(entity), + var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); + + var result = Collection.ReplaceOne( + CreateEntityFilter(entity, true, oldConcurrencyStamp), entity ); + if (result.MatchedCount <= 0) + { + ThrowOptimisticConcurrencyException(); + } + return entity; } @@ -124,32 +132,50 @@ namespace Volo.Abp.Domain.Repositories.MongoDB await TriggerDomainEventsAsync(entity); - await Collection.ReplaceOneAsync( - CreateEntityFilter(entity), + var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); + + var result = await Collection.ReplaceOneAsync( + CreateEntityFilter(entity, true, oldConcurrencyStamp), entity, cancellationToken: GetCancellationToken(cancellationToken) ); + if (result.MatchedCount <= 0) + { + ThrowOptimisticConcurrencyException(); + } + return entity; } public override void Delete(TEntity entity, bool autoSave = false) { AsyncHelper.RunSync(() => ApplyAbpConceptsForDeletedEntityAsync(entity)); + var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); if (entity is ISoftDelete softDeleteEntity) { softDeleteEntity.IsDeleted = true; - Collection.ReplaceOne( - CreateEntityFilter(entity), + var result = Collection.ReplaceOne( + CreateEntityFilter(entity, true, oldConcurrencyStamp), entity ); + + if (result.MatchedCount <= 0) + { + ThrowOptimisticConcurrencyException(); + } } else { - Collection.DeleteOne( - CreateEntityFilter(entity) + var result = Collection.DeleteOne( + CreateEntityFilter(entity, true, oldConcurrencyStamp) ); + + if (result.DeletedCount <= 0) + { + ThrowOptimisticConcurrencyException(); + } } } @@ -159,22 +185,33 @@ namespace Volo.Abp.Domain.Repositories.MongoDB CancellationToken cancellationToken = default) { await ApplyAbpConceptsForDeletedEntityAsync(entity); + var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); if (entity is ISoftDelete softDeleteEntity) { softDeleteEntity.IsDeleted = true; - await Collection.ReplaceOneAsync( - CreateEntityFilter(entity), + var result = await Collection.ReplaceOneAsync( + CreateEntityFilter(entity, true, oldConcurrencyStamp), entity, cancellationToken: GetCancellationToken(cancellationToken) ); + + if (result.MatchedCount <= 0) + { + ThrowOptimisticConcurrencyException(); + } } else { - await Collection.DeleteOneAsync( - CreateEntityFilter(entity), + var result = await Collection.DeleteOneAsync( + CreateEntityFilter(entity, true, oldConcurrencyStamp), GetCancellationToken(cancellationToken) ); + + if (result.DeletedCount <= 0) + { + ThrowOptimisticConcurrencyException(); + } } } @@ -239,7 +276,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB ); } - protected virtual FilterDefinition CreateEntityFilter(TEntity entity) + protected virtual FilterDefinition CreateEntityFilter(TEntity entity, bool withConcurrencyStamp = false, string concurrencyStamp = null) { throw new NotImplementedException( $"{nameof(CreateEntityFilter)} is not implemented for MongoDB by default. It should be overrided and implemented by the deriving class!" @@ -332,6 +369,28 @@ namespace Volo.Abp.Domain.Repositories.MongoDB generatesDomainEventsEntity.ClearDistributedEvents(); } } + + /// + /// Sets a new value + /// if given entity implements interface. + /// Returns the old value. + /// + protected virtual string SetNewConcurrencyStamp(TEntity entity) + { + if (!(entity is IHasConcurrencyStamp concurrencyStampEntity)) + { + return null; + } + + var oldConcurrencyStamp = concurrencyStampEntity.ConcurrencyStamp; + concurrencyStampEntity.ConcurrencyStamp = Guid.NewGuid().ToString("N"); + return oldConcurrencyStamp; + } + + protected virtual void ThrowOptimisticConcurrencyException() + { + throw new AbpDbConcurrencyException("Database operation expected to affect 1 row but actually affected 0 row. Data may have been modified or deleted since entities were loaded. This exception has been thrown on optimistic concurrency check."); + } } public class MongoDbRepository @@ -390,7 +449,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB public virtual void Delete(TKey id, bool autoSave = false) { - Collection.DeleteOne(CreateEntityFilter(id)); + Collection.DeleteOne(CreateEntityFilter(id)); //TODO: How to handle concurrency stamp! } public virtual Task DeleteAsync( @@ -404,9 +463,22 @@ namespace Volo.Abp.Domain.Repositories.MongoDB ); } - protected override FilterDefinition CreateEntityFilter(TEntity entity) + protected override FilterDefinition CreateEntityFilter(TEntity entity, bool withConcurrencyStamp = false, string concurrencyStamp = null) { - return Builders.Filter.Eq(e => e.Id, entity.Id); + if (!withConcurrencyStamp || !(entity is IHasConcurrencyStamp entityWithConcurrencyStamp)) + { + return Builders.Filter.Eq(e => e.Id, entity.Id); + } + + if (concurrencyStamp == null) + { + concurrencyStamp = entityWithConcurrencyStamp.ConcurrencyStamp; + } + + return Builders.Filter.And( + Builders.Filter.Eq(e => e.Id, entity.Id), + Builders.Filter.Eq(e => ((IHasConcurrencyStamp)e).ConcurrencyStamp, concurrencyStamp) + ); } protected virtual FilterDefinition CreateEntityFilter(TKey id, bool applyFilters = false) diff --git a/framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Domain/ConcurrencyStamp_Tests.cs b/framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Domain/ConcurrencyStamp_Tests.cs new file mode 100644 index 0000000000..117cd5dde1 --- /dev/null +++ b/framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Domain/ConcurrencyStamp_Tests.cs @@ -0,0 +1,9 @@ +using Volo.Abp.TestApp.Testing; + +namespace Volo.Abp.MongoDB.Domain +{ + public class ConcurrencyStamp_Tests : ConcurrencyStamp_Tests + { + + } +} diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/ConcurrencyStamp_Tests.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/ConcurrencyStamp_Tests.cs index e74e482cac..2c5a5d89ab 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/ConcurrencyStamp_Tests.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/ConcurrencyStamp_Tests.cs @@ -6,12 +6,12 @@ using Xunit; namespace Volo.Abp.TestApp.Testing { - public class ConcurrencyStamp_Tests : TestAppTestBase + public abstract class ConcurrencyStamp_Tests : TestAppTestBase where TStartupModule : IAbpModule { protected readonly ICityRepository CityRepository; - public ConcurrencyStamp_Tests() + protected ConcurrencyStamp_Tests() { CityRepository = GetRequiredService(); } @@ -19,17 +19,38 @@ namespace Volo.Abp.TestApp.Testing [Fact] public async Task Should_Not_Allow_To_Update_If_The_Entity_Has_Changed() { + //Got an entity from database, changed its value, but not updated in the database yet var london1 = await CityRepository.FindByNameAsync("London"); london1.Name = "London-1"; + //Another user has changed it just before I update var london2 = await CityRepository.FindByNameAsync("London"); london2.Name = "London-2"; await CityRepository.UpdateAsync(london2); + //And updating my old entity throws exception! await Assert.ThrowsAsync(async () => { await CityRepository.UpdateAsync(london1); }); } + + [Fact] + public async Task Should_Not_Allow_To_Delete_If_The_Entity_Has_Changed() + { + //Got an entity from database, but not deleted in the database yet + var london1 = await CityRepository.FindByNameAsync("London"); + + //Another user has changed it just before I delete + var london2 = await CityRepository.FindByNameAsync("London"); + london2.Name = "London-updated"; + await CityRepository.UpdateAsync(london2); + + //And deleting my old entity throws exception! + await Assert.ThrowsAsync(async () => + { + await CityRepository.DeleteAsync(london1); + }); + } } } From 1c3165a32ca9f44314617f59e49cdb6d4572983b Mon Sep 17 00:00:00 2001 From: Mostafa F Date: Wed, 12 Dec 2018 12:48:10 +0330 Subject: [PATCH 2/8] Rename AbpIdentityWebMainMenuContributor.cs to AbpTenantManagementWebMainMenuContributor.cs --- ...tributor.cs => AbpTenantManagementWebMainMenuContributor.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/{AbpIdentityWebMainMenuContributor.cs => AbpTenantManagementWebMainMenuContributor.cs} (99%) diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpIdentityWebMainMenuContributor.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs similarity index 99% rename from modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpIdentityWebMainMenuContributor.cs rename to modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs index ff8dc7f1a6..5726df320e 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpIdentityWebMainMenuContributor.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs @@ -28,4 +28,4 @@ namespace Volo.Abp.TenantManagement.Web.Navigation } } } -} \ No newline at end of file +} From 91020efb075e8d20f8ca4b7a0b8b97200f12a75f Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 12 Dec 2018 13:03:06 +0300 Subject: [PATCH 3/8] Remove unnecessary todo --- .../Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs index b4877d8246..11e79b32e2 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs @@ -10,7 +10,6 @@ using Volo.Abp.Auditing; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities.Events; -using Volo.Abp.EventBus; using Volo.Abp.EventBus.Distributed; using Volo.Abp.EventBus.Local; using Volo.Abp.Guids; @@ -449,7 +448,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB public virtual void Delete(TKey id, bool autoSave = false) { - Collection.DeleteOne(CreateEntityFilter(id)); //TODO: How to handle concurrency stamp! + Collection.DeleteOne(CreateEntityFilter(id)); } public virtual Task DeleteAsync( From d60836c8dbcb09aa8d59bab26f5152eda26eddea Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 12 Dec 2018 14:24:07 +0300 Subject: [PATCH 4/8] #246 Implement concurrency stamp --- .../Abp/EntityFrameworkCore/AbpDbContext.cs | 1 + .../Abp/MongoDB/AbpBsonClassMapExtensions.cs | 5 +- .../Testing/EntityChangeEvents_Tests.cs | 54 +------------------ 3 files changed, 6 insertions(+), 54 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs index 530fb45ccf..6540930405 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs @@ -261,6 +261,7 @@ namespace Volo.Abp.EntityFrameworkCore return; } + Entry(entity).Property(x => x.ConcurrencyStamp).OriginalValue = entity.ConcurrencyStamp; entity.ConcurrencyStamp = Guid.NewGuid().ToString("N"); } diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpBsonClassMapExtensions.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpBsonClassMapExtensions.cs index 67fe25d9b6..68a2719c38 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpBsonClassMapExtensions.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpBsonClassMapExtensions.cs @@ -8,7 +8,10 @@ namespace Volo.Abp.MongoDB public static void ConfigureExtraProperties(this BsonClassMap map) where T : class, IHasExtraProperties { - map.MapExtraElementsProperty(x => x.ExtraProperties); + map.SetExtraElementsMember(new BsonMemberMap( + map, + typeof(T).GetMember(nameof(IHasExtraProperties.ExtraProperties))[0]) + ); } } } diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityChangeEvents_Tests.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityChangeEvents_Tests.cs index 67032507f3..184b7698be 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityChangeEvents_Tests.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/EntityChangeEvents_Tests.cs @@ -35,9 +35,6 @@ namespace Volo.Abp.TestApp.Testing var creatingEventTriggered = false; var createdEventTriggered = false; var createdEtoTriggered = false; - var updatedEtoTriggered = false; - var updatingEventTriggered = false; - var updatedEventTriggered = false; using (var uow = GetRequiredService().Begin()) { @@ -45,18 +42,14 @@ namespace Volo.Abp.TestApp.Testing { creatingEventTriggered.ShouldBeFalse(); createdEventTriggered.ShouldBeFalse(); - updatingEventTriggered.ShouldBeFalse(); - updatedEventTriggered.ShouldBeFalse(); creatingEventTriggered = true; data.Entity.Name.ShouldBe(personName); - /* Want to change age from 15 to 18 - * Expect to trigger EntityUpdatingEventData, EntityUpdatedEventData events */ + /* Want to change age from 15 to 18 */ data.Entity.Age.ShouldBe(15); data.Entity.Age = 18; - PersonRepository.Update(data.Entity); return Task.CompletedTask; }); @@ -64,8 +57,6 @@ namespace Volo.Abp.TestApp.Testing { creatingEventTriggered.ShouldBeTrue(); createdEventTriggered.ShouldBeFalse(); - updatingEventTriggered.ShouldBeTrue(); - updatedEventTriggered.ShouldBeFalse(); createdEventTriggered = true; @@ -84,46 +75,6 @@ namespace Volo.Abp.TestApp.Testing return Task.CompletedTask; }); - LocalEventBus.Subscribe>(data => - { - creatingEventTriggered.ShouldBeTrue(); - createdEventTriggered.ShouldBeFalse(); - updatingEventTriggered.ShouldBeFalse(); - updatedEventTriggered.ShouldBeFalse(); - - updatingEventTriggered = true; - - data.Entity.Name.ShouldBe(personName); - data.Entity.Age.ShouldBe(18); - - return Task.CompletedTask; - }); - - LocalEventBus.Subscribe>(data => - { - creatingEventTriggered.ShouldBeTrue(); - createdEventTriggered.ShouldBeTrue(); - updatingEventTriggered.ShouldBeTrue(); - updatedEventTriggered.ShouldBeFalse(); - - updatedEventTriggered = true; - - data.Entity.Name.ShouldBe(personName); - data.Entity.Age.ShouldBe(18); - - return Task.CompletedTask; - }); - - DistributedEventBus.Subscribe>(eto => - { - eto.Entity.Name.ShouldBe(personName); - eto.Entity.Age.ShouldBe(18); - - updatedEtoTriggered = true; - - return Task.CompletedTask; - }); - PersonRepository.Insert(new Person(Guid.NewGuid(), personName, 15)); uow.Complete(); @@ -132,9 +83,6 @@ namespace Volo.Abp.TestApp.Testing creatingEventTriggered.ShouldBeTrue(); createdEventTriggered.ShouldBeTrue(); createdEtoTriggered.ShouldBeTrue(); - updatingEventTriggered.ShouldBeTrue(); - updatedEventTriggered.ShouldBeTrue(); - updatedEtoTriggered.ShouldBeTrue(); } } } From e664da27f778815faec7374fc978f1637c820054 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 12 Dec 2018 14:34:22 +0300 Subject: [PATCH 5/8] Ignore ConcurrencyStamp and ExtraProperties for mapping --- .../BackgroundJobs/BackgroundJobsDomainAutoMapperProfile.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDomainAutoMapperProfile.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDomainAutoMapperProfile.cs index 2ba2bed8cb..a20a01392b 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDomainAutoMapperProfile.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDomainAutoMapperProfile.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Volo.Abp.AutoMapper; namespace Volo.Abp.BackgroundJobs { @@ -7,6 +8,8 @@ namespace Volo.Abp.BackgroundJobs public BackgroundJobsDomainAutoMapperProfile() { CreateMap() + .Ignore(record => record.ConcurrencyStamp) + .Ignore(record => record.ExtraProperties) .ReverseMap(); } } From 431bfab0bc990250fc7fe817f9e57a2d65836597 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 12 Dec 2018 14:43:24 +0300 Subject: [PATCH 6/8] Use optimistic concurrency in identity user and role edit. Apply migrations for the MVC template. --- .../Application/Services/CrudAppService.cs | 3 +- .../Services/CrudAppServiceBase.cs | 4 +- .../Volo/Abp/Identity/IProfileAppService.cs | 6 +-- .../Volo/Abp/Identity/IdentityRoleDto.cs | 5 ++- .../Abp/Identity/IdentityRoleUpdateDto.cs | 8 ++-- .../Volo/Abp/Identity/IdentityUserDto.cs | 5 ++- .../Abp/Identity/IdentityUserUpdateDto.cs | 7 +++- .../Abp/Identity/IdentityRoleAppService.cs | 1 + .../Abp/Identity/IdentityUserAppService.cs | 1 + .../Abp/Identity/IdentityClaimTypeConsts.cs | 10 +---- .../Volo/Abp/Identity/IdentityRoleConsts.cs | 1 + .../Volo/Abp/Identity/IdentityClaimType.cs | 8 ++-- ...IdentityDbContextModelBuilderExtensions.cs | 7 +++- .../Pages/Identity/Roles/EditModal.cshtml | 3 +- .../Pages/Identity/Roles/EditModal.cshtml.cs | 6 ++- .../Pages/Identity/Users/EditModal.cshtml | 1 + .../Pages/Identity/Users/EditModal.cshtml.cs | 6 ++- .../Identity/IdentityRoleAppService_Tests.cs | 5 ++- .../Identity/IdentityUserAppService_Tests.cs | 39 ++++++++++++++++++- ....cs => 20181212113826_Initial.Designer.cs} | 28 ++++++++++++- ...7_Initial.cs => 20181212113826_Initial.cs} | 14 +++++-- .../MyProjectNameDbContextModelSnapshot.cs | 26 ++++++++++++- ...e.MyProjectName.EntityFrameworkCore.csproj | 4 ++ 23 files changed, 156 insertions(+), 42 deletions(-) rename templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/{20181114070127_Initial.Designer.cs => 20181212113826_Initial.Designer.cs} (95%) rename templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/{20181114070127_Initial.cs => 20181212113826_Initial.cs} (97%) diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs index f705593e87..8127e88f23 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs @@ -1,5 +1,4 @@ using System.Linq; -using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; @@ -99,7 +98,7 @@ namespace Volo.Abp.Application.Services CheckUpdatePolicy(); var entity = GetEntityById(id); - + MapToEntity(input, entity); CurrentUnitOfWork.SaveChanges(); diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs index 947c622081..eb4c7a200f 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs @@ -4,6 +4,7 @@ using System.Linq.Dynamic.Core; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; +using Volo.Abp.ObjectMapping; namespace Volo.Abp.Application.Services { @@ -11,7 +12,8 @@ namespace Volo.Abp.Application.Services /// This is a common base class for CrudAppService and AsyncCrudAppService classes. /// Inherit either from CrudAppService or AsyncCrudAppService, not from this class. /// - public abstract class CrudAppServiceBase : ApplicationService + public abstract class CrudAppServiceBase : + ApplicationService where TEntity : class, IEntity where TEntityDto : IEntityDto { diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs index 9e0a5cbacf..cb61fc6a82 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; +using System.Threading.Tasks; using Volo.Abp.Application.Services; namespace Volo.Abp.Identity diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs index c25ceace56..d55b68fcb1 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs @@ -1,9 +1,10 @@ using System; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; namespace Volo.Abp.Identity { - public class IdentityRoleDto : EntityDto + public class IdentityRoleDto : EntityDto, IHasConcurrencyStamp { public string Name { get; set; } @@ -12,5 +13,7 @@ namespace Volo.Abp.Identity public bool IsStatic { get; set; } public bool IsPublic { get; set; } + + public string ConcurrencyStamp { get; set; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleUpdateDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleUpdateDto.cs index c569957f23..c8a44f92c2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleUpdateDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleUpdateDto.cs @@ -1,7 +1,9 @@ -namespace Volo.Abp.Identity +using Volo.Abp.Domain.Entities; + +namespace Volo.Abp.Identity { - public class IdentityRoleUpdateDto : IdentityRoleCreateOrUpdateDtoBase + public class IdentityRoleUpdateDto : IdentityRoleCreateOrUpdateDtoBase, IHasConcurrencyStamp { - + public string ConcurrencyStamp { get; set; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs index bc28a79f8e..02d1b10166 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs @@ -1,10 +1,11 @@ using System; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; namespace Volo.Abp.Identity { - public class IdentityUserDto : FullAuditedEntityDto, IMultiTenant + public class IdentityUserDto : FullAuditedEntityDto, IMultiTenant, IHasConcurrencyStamp { public Guid? TenantId { get; set; } @@ -27,5 +28,7 @@ namespace Volo.Abp.Identity public bool LockoutEnabled { get; set; } public DateTimeOffset? LockoutEnd { get; set; } + + public string ConcurrencyStamp { get; set; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs index 3117ff8003..a599207f23 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs @@ -1,6 +1,9 @@ -namespace Volo.Abp.Identity +using Volo.Abp.Domain.Entities; + +namespace Volo.Abp.Identity { - public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase + public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase, IHasConcurrencyStamp { + public string ConcurrencyStamp { get; set; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs index f3ad2f880a..ed78156052 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs @@ -84,6 +84,7 @@ namespace Volo.Abp.Identity public async Task UpdateAsync(Guid id, IdentityRoleUpdateDto input) { var role = await _roleManager.GetByIdAsync(id); + role.ConcurrencyStamp = input.ConcurrencyStamp; (await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors(); diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index 054ce247ac..8c9a8ef015 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -72,6 +72,7 @@ namespace Volo.Abp.Identity public async Task UpdateAsync(Guid id, IdentityUserUpdateDto input) { var user = await _userManager.GetByIdAsync(id); + user.ConcurrencyStamp = input.ConcurrencyStamp; (await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors(); await UpdateUserByInput(user, input); diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs index 1b691f404c..32e3197e12 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs @@ -1,17 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Volo.Abp.Identity +namespace Volo.Abp.Identity { public class IdentityClaimTypeConsts { public const int MaxNameLength = 256; - public const int MaxRegexLength = 512; - public const int MaxRegexDescriptionLength = 128; - public const int MaxDescriptionLength = 256; + public const int MaxConcurrencyStampLength = 256; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs index 11bde27f34..cac33aa53d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs @@ -4,5 +4,6 @@ { public const int MaxNameLength = 256; public const int MaxNormalizedNameLength = MaxNameLength; + public const int MaxConcurrencyStampLength = 256; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimType.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimType.cs index 5755279585..d8722669fb 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimType.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimType.cs @@ -1,12 +1,10 @@ using System; -using System.Collections.Generic; -using System.Text; using JetBrains.Annotations; using Volo.Abp.Domain.Entities; namespace Volo.Abp.Identity { - public class IdentityClaimType : Entity + public class IdentityClaimType : AggregateRoot { public virtual string Name { get; protected set; } @@ -24,12 +22,14 @@ namespace Volo.Abp.Identity protected IdentityClaimType() { + } public IdentityClaimType(Guid id, [NotNull] string name, bool required, bool isStatic, [CanBeNull]string regex, [CanBeNull]string regexDescription, [CanBeNull] string description, IdentityClaimValueType valueType = IdentityClaimValueType.String) { Check.NotNull(name, nameof(name)); + Id = id; Name = name; Required = required; IsStatic = isStatic; @@ -38,7 +38,5 @@ namespace Volo.Abp.Identity Description = description; ValueType = valueType; } - - } } diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs index a0ffadea8c..27727da177 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs @@ -30,7 +30,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.Property(u => u.NormalizedEmail).HasMaxLength(IdentityUserConsts.MaxNormalizedEmailLength).HasColumnName(nameof(IdentityUser.NormalizedEmail)); b.Property(u => u.PasswordHash).HasMaxLength(IdentityUserConsts.MaxPasswordHashLength).HasColumnName(nameof(IdentityUser.PasswordHash)); b.Property(u => u.SecurityStamp).IsRequired().HasMaxLength(IdentityUserConsts.MaxSecurityStampLength).HasColumnName(nameof(IdentityUser.SecurityStamp)); - b.Property(u => u.ConcurrencyStamp).IsRequired().HasMaxLength(IdentityUserConsts.MaxConcurrencyStampLength).HasColumnName(nameof(IdentityUser.ConcurrencyStamp)); + b.Property(u => u.ConcurrencyStamp).IsRequired().IsConcurrencyToken().HasMaxLength(IdentityUserConsts.MaxConcurrencyStampLength).HasColumnName(nameof(IdentityUser.ConcurrencyStamp)); b.Property(u => u.TwoFactorEnabled).HasDefaultValue(false).HasColumnName(nameof(IdentityUser.TwoFactorEnabled)); b.Property(u => u.LockoutEnabled).HasDefaultValue(false).HasColumnName(nameof(IdentityUser.LockoutEnabled)); b.Property(u => u.AccessFailedCount).HasDefaultValue(0).HasColumnName(nameof(IdentityUser.AccessFailedCount)); @@ -99,6 +99,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.Property(r => r.Name).IsRequired().HasMaxLength(IdentityRoleConsts.MaxNameLength); b.Property(r => r.NormalizedName).IsRequired().HasMaxLength(IdentityRoleConsts.MaxNormalizedNameLength); + b.Property(u => u.ConcurrencyStamp).IsRequired().IsConcurrencyToken().HasMaxLength(IdentityRoleConsts.MaxConcurrencyStampLength).HasColumnName(nameof(IdentityRole.ConcurrencyStamp)); b.Property(r => r.IsDefault).HasColumnName(nameof(IdentityRole.IsDefault)); b.Property(r => r.IsStatic).HasColumnName(nameof(IdentityRole.IsStatic)); b.Property(r => r.IsPublic).HasColumnName(nameof(IdentityRole.IsPublic)); @@ -122,11 +123,13 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { b.ToTable(options.TablePrefix + "ClaimTypes", options.Schema); + b.ConfigureExtraProperties(); + b.Property(uc => uc.Name).HasMaxLength(IdentityClaimTypeConsts.MaxNameLength).IsRequired(); // make unique b.Property(uc => uc.Regex).HasMaxLength(IdentityClaimTypeConsts.MaxRegexLength); b.Property(uc => uc.RegexDescription).HasMaxLength(IdentityClaimTypeConsts.MaxRegexDescriptionLength); b.Property(uc => uc.Description).HasMaxLength(IdentityClaimTypeConsts.MaxDescriptionLength); - + b.Property(uc => uc.ConcurrencyStamp).IsRequired().IsConcurrencyToken().HasMaxLength(IdentityClaimTypeConsts.MaxConcurrencyStampLength).HasColumnName(nameof(IdentityClaimType.ConcurrencyStamp)); }); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml index b09cfe2dcb..0a3cd3668d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml @@ -12,9 +12,10 @@ + @if (Model.Role.IsStatic) { - + } else { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs index 58703c211e..66259c6ba0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Abp.Domain.Entities; namespace Volo.Abp.Identity.Web.Pages.Identity.Roles { @@ -35,11 +36,14 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles return NoContent(); } - public class RoleInfoModel + public class RoleInfoModel : IHasConcurrencyStamp { [HiddenInput] public Guid Id { get; set; } + [HiddenInput] + public string ConcurrencyStamp { get; set; } + [Required] [StringLength(IdentityRoleConsts.MaxNameLength)] [Display(Name = "DisplayName:RoleName")] diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml index afa0df85ed..be9cc9b205 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml @@ -15,6 +15,7 @@ @* TODO: Can we use dynamic form? *@ + diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index 25615aca94..0655331fb9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Abp.Domain.Entities; namespace Volo.Abp.Identity.Web.Pages.Identity.Users { @@ -54,11 +55,14 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users return NoContent(); } - public class UserInfoViewModel + public class UserInfoViewModel : IHasConcurrencyStamp { [HiddenInput] public Guid Id { get; set; } + [HiddenInput] + public string ConcurrencyStamp { get; set; } + [Required] [StringLength(IdentityUserConsts.MaxUserNameLength)] public string UserName { get; set; } diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs index 8801f7073a..d20294da5c 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs @@ -78,7 +78,10 @@ namespace Volo.Abp.Identity var input = new IdentityRoleUpdateDto { - Name = Guid.NewGuid().ToString("N").Left(8) + Name = Guid.NewGuid().ToString("N").Left(8), + ConcurrencyStamp = moderator.ConcurrencyStamp, + IsDefault = moderator.IsDefault, + IsPublic = moderator.IsPublic }; //Act diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs index 14864ce7da..c418c261ff 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Shouldly; +using Volo.Abp.Data; using Xunit; namespace Volo.Abp.Identity @@ -9,11 +10,13 @@ namespace Volo.Abp.Identity { private readonly IIdentityUserAppService _userAppService; private readonly IIdentityUserRepository _userRepository; + private readonly IdentityTestData _testData; public IdentityUserAppService_Tests() { _userAppService = GetRequiredService(); _userRepository = GetRequiredService(); + _testData = GetRequiredService(); } [Fact] @@ -98,7 +101,10 @@ namespace Volo.Abp.Identity TwoFactorEnabled = true, PhoneNumber = CreateRandomPhoneNumber(), Email = CreateRandomEmail(), - RoleNames = new[] { "admin", "moderator" } + RoleNames = new[] { "admin", "moderator" }, + ConcurrencyStamp = johnNash.ConcurrencyStamp, + Surname = johnNash.Surname, + Name = johnNash.Name }; //Act @@ -122,6 +128,37 @@ namespace Volo.Abp.Identity user.Roles.Count.ShouldBe(2); } + + [Fact] + public async Task UpdateAsync_Concurrency_Exception() + { + //Get user + var johnNash = await _userAppService.GetAsync(_testData.UserJohnId); + + //Act + + var input = new IdentityUserUpdateDto + { + Name = "John-updated", + Surname = "Nash-updated", + UserName = johnNash.UserName, + LockoutEnabled = true, + TwoFactorEnabled = true, + PhoneNumber = CreateRandomPhoneNumber(), + Email = CreateRandomEmail(), + RoleNames = new[] { "admin", "moderator" }, + ConcurrencyStamp = johnNash.ConcurrencyStamp + }; + + await _userAppService.UpdateAsync(johnNash.Id, input); + + //Second update with same input will throw exception because the entity has been modified + (await Assert.ThrowsAsync(async () => + { + await _userAppService.UpdateAsync(johnNash.Id, input); + })).Message.ShouldContain("Optimistic concurrency failure"); + } + [Fact] public async Task DeleteAsync() { diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181114070127_Initial.Designer.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181212113826_Initial.Designer.cs similarity index 95% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181114070127_Initial.Designer.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181212113826_Initial.Designer.cs index 9abe09e5c4..8afbe89363 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181114070127_Initial.Designer.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181212113826_Initial.Designer.cs @@ -11,7 +11,7 @@ using Volo.Abp.BackgroundJobs; namespace MyCompanyName.MyProjectName.Migrations { [DbContext(typeof(MyProjectNameDbContext))] - [Migration("20181114070127_Initial")] + [Migration("20181212113826_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -43,6 +43,8 @@ namespace MyCompanyName.MyProjectName.Migrations .HasColumnName("Comments") .HasMaxLength(256); + b.Property("ConcurrencyStamp"); + b.Property("Exceptions") .HasColumnName("Exceptions") .HasMaxLength(4000); @@ -221,9 +223,14 @@ namespace MyCompanyName.MyProjectName.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp"); + b.Property("CreationTime") .HasColumnName("CreationTime"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("IsAbandoned") .ValueGeneratedOnAdd() .HasDefaultValue(false); @@ -260,9 +267,18 @@ namespace MyCompanyName.MyProjectName.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + b.Property("Description") .HasMaxLength(256); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("IsStatic"); b.Property("Name") @@ -289,7 +305,14 @@ namespace MyCompanyName.MyProjectName.Migrations b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); b.Property("IsDefault") .HasColumnName("IsDefault"); @@ -351,6 +374,7 @@ namespace MyCompanyName.MyProjectName.Migrations .HasDefaultValue(0); b.Property("ConcurrencyStamp") + .IsConcurrencyToken() .IsRequired() .HasColumnName("ConcurrencyStamp") .HasMaxLength(256); diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181114070127_Initial.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181212113826_Initial.cs similarity index 97% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181114070127_Initial.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181212113826_Initial.cs index 01f4f9cd7f..5dd6559191 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181114070127_Initial.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181212113826_Initial.cs @@ -12,6 +12,7 @@ namespace MyCompanyName.MyProjectName.Migrations columns: table => new { Id = table.Column(nullable: false), + ConcurrencyStamp = table.Column(nullable: true), UserId = table.Column(nullable: true), UserName = table.Column(maxLength: 256, nullable: true), TenantId = table.Column(nullable: true), @@ -39,6 +40,8 @@ namespace MyCompanyName.MyProjectName.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), JobName = table.Column(maxLength: 128, nullable: false), JobArgs = table.Column(maxLength: 1048576, nullable: false), TryCount = table.Column(nullable: false, defaultValue: (short)0), @@ -58,6 +61,8 @@ namespace MyCompanyName.MyProjectName.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), Name = table.Column(maxLength: 256, nullable: false), Required = table.Column(nullable: false), IsStatic = table.Column(nullable: false), @@ -91,10 +96,11 @@ namespace MyCompanyName.MyProjectName.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), TenantId = table.Column(nullable: true), Name = table.Column(maxLength: 256, nullable: false), NormalizedName = table.Column(maxLength: 256, nullable: false), - ConcurrencyStamp = table.Column(nullable: true), IsDefault = table.Column(nullable: false), IsStatic = table.Column(nullable: false), IsPublic = table.Column(nullable: false) @@ -124,6 +130,8 @@ namespace MyCompanyName.MyProjectName.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), CreationTime = table.Column(nullable: false), CreatorId = table.Column(nullable: true), LastModificationTime = table.Column(nullable: true), @@ -141,14 +149,12 @@ namespace MyCompanyName.MyProjectName.Migrations EmailConfirmed = table.Column(nullable: false, defaultValue: false), PasswordHash = table.Column(maxLength: 256, nullable: true), SecurityStamp = table.Column(maxLength: 256, nullable: false), - ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), PhoneNumber = table.Column(maxLength: 16, nullable: true), PhoneNumberConfirmed = table.Column(nullable: false, defaultValue: false), TwoFactorEnabled = table.Column(nullable: false, defaultValue: false), LockoutEnd = table.Column(nullable: true), LockoutEnabled = table.Column(nullable: false, defaultValue: false), - AccessFailedCount = table.Column(nullable: false, defaultValue: 0), - ExtraProperties = table.Column(nullable: true) + AccessFailedCount = table.Column(nullable: false, defaultValue: 0) }, constraints: table => { diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs index eff7489955..8a05ab5bc3 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs @@ -41,6 +41,8 @@ namespace MyCompanyName.MyProjectName.Migrations .HasColumnName("Comments") .HasMaxLength(256); + b.Property("ConcurrencyStamp"); + b.Property("Exceptions") .HasColumnName("Exceptions") .HasMaxLength(4000); @@ -219,9 +221,14 @@ namespace MyCompanyName.MyProjectName.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp"); + b.Property("CreationTime") .HasColumnName("CreationTime"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("IsAbandoned") .ValueGeneratedOnAdd() .HasDefaultValue(false); @@ -258,9 +265,18 @@ namespace MyCompanyName.MyProjectName.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + b.Property("Description") .HasMaxLength(256); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("IsStatic"); b.Property("Name") @@ -287,7 +303,14 @@ namespace MyCompanyName.MyProjectName.Migrations b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); b.Property("IsDefault") .HasColumnName("IsDefault"); @@ -349,6 +372,7 @@ namespace MyCompanyName.MyProjectName.Migrations .HasDefaultValue(0); b.Property("ConcurrencyStamp") + .IsConcurrencyToken() .IsRequired() .HasColumnName("ConcurrencyStamp") .HasMaxLength(256); diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj index c3e54f4327..c393a58161 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj @@ -5,6 +5,10 @@ MyCompanyName.MyProjectName + + + + From 5674fc39ae5382963213b666568f68f53c0aefee Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 12 Dec 2018 14:55:44 +0300 Subject: [PATCH 7/8] Update migration --- ....cs => 20181212114934_Initial.Designer.cs} | 86 ++++++++++++++++++- ...9_Initial.cs => 20181212114934_Initial.cs} | 48 +++++++++-- .../DemoAppDbContextModelSnapshot.cs | 84 +++++++++++++++++- ...MyCompanyName.MyProjectName.DemoApp.csproj | 8 -- 4 files changed, 205 insertions(+), 21 deletions(-) rename templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/{20180711153639_Initial.Designer.cs => 20181212114934_Initial.Designer.cs} (80%) rename templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/{20180711153639_Initial.cs => 20181212114934_Initial.cs} (83%) diff --git a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20180711153639_Initial.Designer.cs b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181212114934_Initial.Designer.cs similarity index 80% rename from templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20180711153639_Initial.Designer.cs rename to templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181212114934_Initial.Designer.cs index 7f69d96beb..9f8a2b4adf 100644 --- a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20180711153639_Initial.Designer.cs +++ b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181212114934_Initial.Designer.cs @@ -10,7 +10,7 @@ using MyCompanyName.MyProjectName.DemoApp; namespace MyCompanyName.MyProjectName.DemoApp.Migrations { [DbContext(typeof(DemoAppDbContext))] - [Migration("20180711153639_Initial")] + [Migration("20181212114934_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -21,12 +21,66 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("Description") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256); + + b.Property("Regex") + .HasMaxLength(512); + + b.Property("RegexDescription") + .HasMaxLength(128); + + b.Property("Required"); + + b.Property("ValueType"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => { b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnName("IsStatic"); b.Property("Name") .IsRequired() @@ -79,10 +133,19 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasDefaultValue(0); b.Property("ConcurrencyStamp") + .IsConcurrencyToken() .IsRequired() .HasColumnName("ConcurrencyStamp") .HasMaxLength(256); + b.Property("CreationTime"); + + b.Property("CreatorId"); + + b.Property("DeleterId"); + + b.Property("DeletionTime"); + b.Property("Email") .HasColumnName("Email") .HasMaxLength(256); @@ -95,6 +158,12 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.Property("ExtraProperties") .HasColumnName("ExtraProperties"); + b.Property("IsDeleted"); + + b.Property("LastModificationTime"); + + b.Property("LastModifierId"); + b.Property("LockoutEnabled") .ValueGeneratedOnAdd() .HasColumnName("LockoutEnabled") @@ -102,6 +171,10 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.Property("LockoutEnd"); + b.Property("Name") + .HasColumnName("Name") + .HasMaxLength(64); + b.Property("NormalizedEmail") .HasColumnName("NormalizedEmail") .HasMaxLength(256); @@ -129,6 +202,10 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasColumnName("SecurityStamp") .HasMaxLength(256); + b.Property("Surname") + .HasColumnName("Surname") + .HasMaxLength(64); + b.Property("TenantId") .HasColumnName("TenantId"); @@ -221,9 +298,10 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.Property("UserId"); b.Property("LoginProvider") - .HasMaxLength(128); + .HasMaxLength(64); - b.Property("Name"); + b.Property("Name") + .HasMaxLength(128); b.Property("TenantId"); diff --git a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20180711153639_Initial.cs b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181212114934_Initial.cs similarity index 83% rename from templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20180711153639_Initial.cs rename to templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181212114934_Initial.cs index 68dae7e9c6..cefa12dfaf 100644 --- a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20180711153639_Initial.cs +++ b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181212114934_Initial.cs @@ -7,6 +7,26 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), + Name = table.Column(maxLength: 256, nullable: false), + Required = table.Column(nullable: false), + IsStatic = table.Column(nullable: false), + Regex = table.Column(maxLength: 512, nullable: true), + RegexDescription = table.Column(maxLength: 128, nullable: true), + Description = table.Column(maxLength: 256, nullable: true), + ValueType = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + migrationBuilder.CreateTable( name: "AbpPermissionGrants", columns: table => new @@ -27,10 +47,14 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), TenantId = table.Column(nullable: true), Name = table.Column(maxLength: 256, nullable: false), NormalizedName = table.Column(maxLength: 256, nullable: false), - ConcurrencyStamp = table.Column(nullable: true) + IsDefault = table.Column(nullable: false), + IsStatic = table.Column(nullable: false), + IsPublic = table.Column(nullable: false) }, constraints: table => { @@ -57,22 +81,31 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), TenantId = table.Column(nullable: true), UserName = table.Column(maxLength: 256, nullable: false), NormalizedUserName = table.Column(maxLength: 256, nullable: false), + Name = table.Column(maxLength: 64, nullable: true), + Surname = table.Column(maxLength: 64, nullable: true), Email = table.Column(maxLength: 256, nullable: true), NormalizedEmail = table.Column(maxLength: 256, nullable: true), EmailConfirmed = table.Column(nullable: false, defaultValue: false), PasswordHash = table.Column(maxLength: 256, nullable: true), SecurityStamp = table.Column(maxLength: 256, nullable: false), - ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), PhoneNumber = table.Column(maxLength: 16, nullable: true), PhoneNumberConfirmed = table.Column(nullable: false, defaultValue: false), TwoFactorEnabled = table.Column(nullable: false, defaultValue: false), LockoutEnd = table.Column(nullable: true), LockoutEnabled = table.Column(nullable: false, defaultValue: false), - AccessFailedCount = table.Column(nullable: false, defaultValue: 0), - ExtraProperties = table.Column(nullable: true) + AccessFailedCount = table.Column(nullable: false, defaultValue: 0) }, constraints: table => { @@ -173,8 +206,8 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations { TenantId = table.Column(nullable: true), UserId = table.Column(nullable: false), - LoginProvider = table.Column(maxLength: 128, nullable: false), - Name = table.Column(nullable: false), + LoginProvider = table.Column(maxLength: 64, nullable: false), + Name = table.Column(maxLength: 128, nullable: false), Value = table.Column(nullable: true) }, constraints: table => @@ -246,6 +279,9 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations protected override void Down(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "AbpClaimTypes"); + migrationBuilder.DropTable( name: "AbpPermissionGrants"); diff --git a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs index ad9f1b82c9..b64a132e07 100644 --- a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs +++ b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs @@ -19,12 +19,66 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("Description") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256); + + b.Property("Regex") + .HasMaxLength(512); + + b.Property("RegexDescription") + .HasMaxLength(128); + + b.Property("Required"); + + b.Property("ValueType"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => { b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnName("IsStatic"); b.Property("Name") .IsRequired() @@ -77,10 +131,19 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasDefaultValue(0); b.Property("ConcurrencyStamp") + .IsConcurrencyToken() .IsRequired() .HasColumnName("ConcurrencyStamp") .HasMaxLength(256); + b.Property("CreationTime"); + + b.Property("CreatorId"); + + b.Property("DeleterId"); + + b.Property("DeletionTime"); + b.Property("Email") .HasColumnName("Email") .HasMaxLength(256); @@ -93,6 +156,12 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.Property("ExtraProperties") .HasColumnName("ExtraProperties"); + b.Property("IsDeleted"); + + b.Property("LastModificationTime"); + + b.Property("LastModifierId"); + b.Property("LockoutEnabled") .ValueGeneratedOnAdd() .HasColumnName("LockoutEnabled") @@ -100,6 +169,10 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.Property("LockoutEnd"); + b.Property("Name") + .HasColumnName("Name") + .HasMaxLength(64); + b.Property("NormalizedEmail") .HasColumnName("NormalizedEmail") .HasMaxLength(256); @@ -127,6 +200,10 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasColumnName("SecurityStamp") .HasMaxLength(256); + b.Property("Surname") + .HasColumnName("Surname") + .HasMaxLength(64); + b.Property("TenantId") .HasColumnName("TenantId"); @@ -219,9 +296,10 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.Property("UserId"); b.Property("LoginProvider") - .HasMaxLength(128); + .HasMaxLength(64); - b.Property("Name"); + b.Property("Name") + .HasMaxLength(128); b.Property("TenantId"); diff --git a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj index 054c032e18..c42f5f663c 100644 --- a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj +++ b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj @@ -33,12 +33,4 @@ - - - - - - - - From 67086b466aec9197a54dcd8a0d294efe83547a6a Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 12 Dec 2018 15:13:28 +0300 Subject: [PATCH 8/8] Update migrations. --- .../20181031075019_Initial.Designer.cs | 526 ------------------ .../20181031081104_Added_Identity.cs | 252 --------- ....cs => 20181212121034_Initial.Designer.cs} | 74 ++- ...9_Initial.cs => 20181212121034_Initial.cs} | 261 +++++++++ .../DemoAppDbContextModelSnapshot.cs | 70 ++- ....cs => 20181212121232_Initial.Designer.cs} | 4 +- ...0_Initial.cs => 20181212121232_Initial.cs} | 5 +- .../DemoAppDbContextModelSnapshot.cs | 2 + 8 files changed, 409 insertions(+), 785 deletions(-) delete mode 100644 templates/service/host/IdentityServerHost/Migrations/20181031075019_Initial.Designer.cs delete mode 100644 templates/service/host/IdentityServerHost/Migrations/20181031081104_Added_Identity.cs rename templates/service/host/IdentityServerHost/Migrations/{20181031081104_Added_Identity.Designer.cs => 20181212121034_Initial.Designer.cs} (91%) rename templates/service/host/IdentityServerHost/Migrations/{20181031075019_Initial.cs => 20181212121034_Initial.cs} (63%) rename templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/{20181030142530_Initial.Designer.cs => 20181212121232_Initial.Designer.cs} (99%) rename templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/{20181030142530_Initial.cs => 20181212121232_Initial.cs} (99%) diff --git a/templates/service/host/IdentityServerHost/Migrations/20181031075019_Initial.Designer.cs b/templates/service/host/IdentityServerHost/Migrations/20181031075019_Initial.Designer.cs deleted file mode 100644 index 6b85820f8a..0000000000 --- a/templates/service/host/IdentityServerHost/Migrations/20181031075019_Initial.Designer.cs +++ /dev/null @@ -1,526 +0,0 @@ -// -using System; -using IdentityServerHost; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace IdentityServerHost.Migrations -{ - [DbContext(typeof(DemoAppDbContext))] - [Migration("20181031075019_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.1.1-rtm-30846") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Description") - .HasMaxLength(1000); - - b.Property("DisplayName") - .HasMaxLength(200); - - b.Property("Enabled"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200); - - b.HasKey("Id"); - - b.ToTable("IdentityServerApiResources"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => - { - b.Property("ApiResourceId"); - - b.Property("Type") - .HasMaxLength(196); - - b.HasKey("ApiResourceId", "Type"); - - b.ToTable("IdentityServerApiClaims"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => - { - b.Property("ApiResourceId"); - - b.Property("Name") - .HasMaxLength(196); - - b.Property("Description") - .HasMaxLength(256); - - b.Property("DisplayName") - .HasMaxLength(128); - - b.Property("Emphasize"); - - b.Property("Required"); - - b.Property("ShowInDiscoveryDocument"); - - b.HasKey("ApiResourceId", "Name"); - - b.ToTable("IdentityServerApiScopes"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => - { - b.Property("ApiResourceId"); - - b.Property("Name") - .HasMaxLength(196); - - b.Property("Type") - .HasMaxLength(196); - - b.HasKey("ApiResourceId", "Name", "Type"); - - b.ToTable("IdentityServerApiScopeClaims"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => - { - b.Property("ApiResourceId"); - - b.Property("Type") - .HasMaxLength(32); - - b.Property("Value") - .HasMaxLength(196); - - b.Property("Description") - .HasMaxLength(256); - - b.Property("Expiration"); - - b.HasKey("ApiResourceId", "Type", "Value"); - - b.ToTable("IdentityServerApiSecrets"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("AbsoluteRefreshTokenLifetime"); - - b.Property("AccessTokenLifetime"); - - b.Property("AccessTokenType"); - - b.Property("AllowAccessTokensViaBrowser"); - - b.Property("AllowOfflineAccess"); - - b.Property("AllowPlainTextPkce"); - - b.Property("AllowRememberConsent"); - - b.Property("AlwaysIncludeUserClaimsInIdToken"); - - b.Property("AlwaysSendClientClaims"); - - b.Property("AuthorizationCodeLifetime"); - - b.Property("BackChannelLogoutSessionRequired"); - - b.Property("BackChannelLogoutUri") - .HasMaxLength(2000); - - b.Property("ClientClaimsPrefix") - .HasMaxLength(200); - - b.Property("ClientId") - .IsRequired() - .HasMaxLength(200); - - b.Property("ClientName") - .HasMaxLength(200); - - b.Property("ClientUri") - .HasMaxLength(2000); - - b.Property("ConsentLifetime"); - - b.Property("Description") - .HasMaxLength(1000); - - b.Property("EnableLocalLogin"); - - b.Property("Enabled"); - - b.Property("FrontChannelLogoutSessionRequired"); - - b.Property("FrontChannelLogoutUri") - .HasMaxLength(2000); - - b.Property("IdentityTokenLifetime"); - - b.Property("IncludeJwtId"); - - b.Property("LogoUri") - .HasMaxLength(2000); - - b.Property("PairWiseSubjectSalt") - .HasMaxLength(200); - - b.Property("ProtocolType") - .IsRequired() - .HasMaxLength(200); - - b.Property("RefreshTokenExpiration"); - - b.Property("RefreshTokenUsage"); - - b.Property("RequireClientSecret"); - - b.Property("RequireConsent"); - - b.Property("RequirePkce"); - - b.Property("SlidingRefreshTokenLifetime"); - - b.Property("UpdateAccessTokenClaimsOnRefresh"); - - b.HasKey("Id"); - - b.HasIndex("ClientId") - .IsUnique(); - - b.ToTable("IdentityServerClients"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ClientId"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(250); - - b.Property("Value") - .IsRequired() - .HasMaxLength(250); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("IdentityServerClientClaims"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => - { - b.Property("ClientId"); - - b.Property("Origin") - .HasMaxLength(150); - - b.HasKey("ClientId", "Origin"); - - b.ToTable("IdentityServerClientCorsOrigins"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => - { - b.Property("ClientId"); - - b.Property("GrantType") - .HasMaxLength(196); - - b.HasKey("ClientId", "GrantType"); - - b.ToTable("IdentityServerClientGrantTypes"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => - { - b.Property("ClientId"); - - b.Property("Provider") - .HasMaxLength(64); - - b.HasKey("ClientId", "Provider"); - - b.ToTable("IdentityServerClientIdPRestrictions"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => - { - b.Property("ClientId"); - - b.Property("PostLogoutRedirectUri") - .HasMaxLength(2000); - - b.HasKey("ClientId", "PostLogoutRedirectUri"); - - b.ToTable("IdentityServerClientPostLogoutRedirectUris"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => - { - b.Property("ClientId"); - - b.Property("Key") - .HasMaxLength(250); - - b.Property("Value") - .IsRequired() - .HasMaxLength(2000); - - b.HasKey("ClientId", "Key"); - - b.ToTable("IdentityServerClientProperties"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => - { - b.Property("ClientId"); - - b.Property("RedirectUri") - .HasMaxLength(2000); - - b.HasKey("ClientId", "RedirectUri"); - - b.ToTable("IdentityServerClientRedirectUris"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => - { - b.Property("ClientId"); - - b.Property("Scope") - .HasMaxLength(196); - - b.HasKey("ClientId", "Scope"); - - b.ToTable("IdentityServerClientScopes"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => - { - b.Property("ClientId"); - - b.Property("Type") - .HasMaxLength(32); - - b.Property("Value") - .HasMaxLength(196); - - b.Property("Description") - .HasMaxLength(256); - - b.Property("Expiration"); - - b.HasKey("ClientId", "Type", "Value"); - - b.ToTable("IdentityServerClientSecrets"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b => - { - b.Property("Key") - .HasMaxLength(200); - - b.Property("ClientId") - .IsRequired() - .HasMaxLength(200); - - b.Property("CreationTime"); - - b.Property("Data") - .IsRequired(); - - b.Property("Expiration"); - - b.Property("Id"); - - b.Property("SubjectId") - .HasMaxLength(200); - - b.Property("Type") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Key"); - - b.HasIndex("SubjectId", "ClientId", "Type"); - - b.ToTable("IdentityServerPersistedGrants"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => - { - b.Property("IdentityResourceId"); - - b.Property("Type") - .HasMaxLength(196); - - b.HasKey("IdentityResourceId", "Type"); - - b.ToTable("IdentityServerIdentityClaims"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Description") - .HasMaxLength(1000); - - b.Property("DisplayName") - .HasMaxLength(200); - - b.Property("Emphasize"); - - b.Property("Enabled"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200); - - b.Property("Required"); - - b.Property("ShowInDiscoveryDocument"); - - b.HasKey("Id"); - - b.ToTable("IdentityServerIdentityResources"); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => - { - b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") - .WithMany("UserClaims") - .HasForeignKey("ApiResourceId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => - { - b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") - .WithMany("Scopes") - .HasForeignKey("ApiResourceId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => - { - b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiScope") - .WithMany("UserClaims") - .HasForeignKey("ApiResourceId", "Name") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => - { - b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") - .WithMany("Secrets") - .HasForeignKey("ApiResourceId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("Claims") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("AllowedCorsOrigins") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("AllowedGrantTypes") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("IdentityProviderRestrictions") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("PostLogoutRedirectUris") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("Properties") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("RedirectUris") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("AllowedScopes") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => - { - b.HasOne("Volo.Abp.IdentityServer.Clients.Client") - .WithMany("ClientSecrets") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => - { - b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource") - .WithMany("UserClaims") - .HasForeignKey("IdentityResourceId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/templates/service/host/IdentityServerHost/Migrations/20181031081104_Added_Identity.cs b/templates/service/host/IdentityServerHost/Migrations/20181031081104_Added_Identity.cs deleted file mode 100644 index e0f5642cd7..0000000000 --- a/templates/service/host/IdentityServerHost/Migrations/20181031081104_Added_Identity.cs +++ /dev/null @@ -1,252 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace IdentityServerHost.Migrations -{ - public partial class Added_Identity : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpClaimTypes", - columns: table => new - { - Id = table.Column(nullable: false), - Name = table.Column(maxLength: 256, nullable: false), - Required = table.Column(nullable: false), - IsStatic = table.Column(nullable: false), - Regex = table.Column(maxLength: 512, nullable: true), - RegexDescription = table.Column(maxLength: 128, nullable: true), - Description = table.Column(maxLength: 256, nullable: true), - ValueType = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoles", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - Name = table.Column(maxLength: 256, nullable: false), - NormalizedName = table.Column(maxLength: 256, nullable: false), - ConcurrencyStamp = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpUsers", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - UserName = table.Column(maxLength: 256, nullable: false), - NormalizedUserName = table.Column(maxLength: 256, nullable: false), - Email = table.Column(maxLength: 256, nullable: true), - NormalizedEmail = table.Column(maxLength: 256, nullable: true), - EmailConfirmed = table.Column(nullable: false, defaultValue: false), - PasswordHash = table.Column(maxLength: 256, nullable: true), - SecurityStamp = table.Column(maxLength: 256, nullable: false), - ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), - PhoneNumber = table.Column(maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(nullable: false, defaultValue: false), - TwoFactorEnabled = table.Column(nullable: false, defaultValue: false), - LockoutEnd = table.Column(nullable: true), - LockoutEnabled = table.Column(nullable: false, defaultValue: false), - AccessFailedCount = table.Column(nullable: false, defaultValue: 0), - ExtraProperties = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoleClaims", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - ClaimType = table.Column(maxLength: 256, nullable: false), - ClaimValue = table.Column(maxLength: 1024, nullable: true), - RoleId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpRoleClaims_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserClaims", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - ClaimType = table.Column(maxLength: 256, nullable: false), - ClaimValue = table.Column(maxLength: 1024, nullable: true), - UserId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpUserClaims_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserLogins", - columns: table => new - { - TenantId = table.Column(nullable: true), - UserId = table.Column(nullable: false), - LoginProvider = table.Column(maxLength: 64, nullable: false), - ProviderKey = table.Column(maxLength: 196, nullable: false), - ProviderDisplayName = table.Column(maxLength: 128, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); - table.ForeignKey( - name: "FK_AbpUserLogins_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserRoles", - columns: table => new - { - TenantId = table.Column(nullable: true), - UserId = table.Column(nullable: false), - RoleId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserTokens", - columns: table => new - { - TenantId = table.Column(nullable: true), - UserId = table.Column(nullable: false), - LoginProvider = table.Column(maxLength: 64, nullable: false), - Name = table.Column(maxLength: 128, nullable: false), - Value = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AbpUserTokens_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoleClaims_RoleId", - table: "AbpRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoles_NormalizedName", - table: "AbpRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserClaims_UserId", - table: "AbpUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserLogins_LoginProvider_ProviderKey", - table: "AbpUserLogins", - columns: new[] { "LoginProvider", "ProviderKey" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserRoles_RoleId_UserId", - table: "AbpUserRoles", - columns: new[] { "RoleId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_Email", - table: "AbpUsers", - column: "Email"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedEmail", - table: "AbpUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedUserName", - table: "AbpUsers", - column: "NormalizedUserName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_UserName", - table: "AbpUsers", - column: "UserName"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AbpClaimTypes"); - - migrationBuilder.DropTable( - name: "AbpRoleClaims"); - - migrationBuilder.DropTable( - name: "AbpUserClaims"); - - migrationBuilder.DropTable( - name: "AbpUserLogins"); - - migrationBuilder.DropTable( - name: "AbpUserRoles"); - - migrationBuilder.DropTable( - name: "AbpUserTokens"); - - migrationBuilder.DropTable( - name: "AbpRoles"); - - migrationBuilder.DropTable( - name: "AbpUsers"); - } - } -} diff --git a/templates/service/host/IdentityServerHost/Migrations/20181031081104_Added_Identity.Designer.cs b/templates/service/host/IdentityServerHost/Migrations/20181212121034_Initial.Designer.cs similarity index 91% rename from templates/service/host/IdentityServerHost/Migrations/20181031081104_Added_Identity.Designer.cs rename to templates/service/host/IdentityServerHost/Migrations/20181212121034_Initial.Designer.cs index e3603c4fec..63b2af58a7 100644 --- a/templates/service/host/IdentityServerHost/Migrations/20181031081104_Added_Identity.Designer.cs +++ b/templates/service/host/IdentityServerHost/Migrations/20181212121034_Initial.Designer.cs @@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace IdentityServerHost.Migrations { [DbContext(typeof(DemoAppDbContext))] - [Migration("20181031081104_Added_Identity")] - partial class Added_Identity + [Migration("20181212121034_Initial")] + partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -26,9 +26,18 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + b.Property("Description") .HasMaxLength(256); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("IsStatic"); b.Property("Name") @@ -55,7 +64,23 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnName("IsStatic"); b.Property("Name") .IsRequired() @@ -108,10 +133,19 @@ namespace IdentityServerHost.Migrations .HasDefaultValue(0); b.Property("ConcurrencyStamp") + .IsConcurrencyToken() .IsRequired() .HasColumnName("ConcurrencyStamp") .HasMaxLength(256); + b.Property("CreationTime"); + + b.Property("CreatorId"); + + b.Property("DeleterId"); + + b.Property("DeletionTime"); + b.Property("Email") .HasColumnName("Email") .HasMaxLength(256); @@ -124,6 +158,12 @@ namespace IdentityServerHost.Migrations b.Property("ExtraProperties") .HasColumnName("ExtraProperties"); + b.Property("IsDeleted"); + + b.Property("LastModificationTime"); + + b.Property("LastModifierId"); + b.Property("LockoutEnabled") .ValueGeneratedOnAdd() .HasColumnName("LockoutEnabled") @@ -131,6 +171,10 @@ namespace IdentityServerHost.Migrations b.Property("LockoutEnd"); + b.Property("Name") + .HasColumnName("Name") + .HasMaxLength(64); + b.Property("NormalizedEmail") .HasColumnName("NormalizedEmail") .HasMaxLength(256); @@ -158,6 +202,10 @@ namespace IdentityServerHost.Migrations .HasColumnName("SecurityStamp") .HasMaxLength(256); + b.Property("Surname") + .HasColumnName("Surname") + .HasMaxLength(64); + b.Property("TenantId") .HasColumnName("TenantId"); @@ -269,6 +317,8 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp"); + b.Property("Description") .HasMaxLength(1000); @@ -277,6 +327,9 @@ namespace IdentityServerHost.Migrations b.Property("Enabled"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("Name") .IsRequired() .HasMaxLength(200); @@ -400,6 +453,8 @@ namespace IdentityServerHost.Migrations b.Property("ClientUri") .HasMaxLength(2000); + b.Property("ConcurrencyStamp"); + b.Property("ConsentLifetime"); b.Property("Description") @@ -409,6 +464,9 @@ namespace IdentityServerHost.Migrations b.Property("Enabled"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("FrontChannelLogoutSessionRequired"); b.Property("FrontChannelLogoutUri") @@ -589,6 +647,8 @@ namespace IdentityServerHost.Migrations .IsRequired() .HasMaxLength(200); + b.Property("ConcurrencyStamp"); + b.Property("CreationTime"); b.Property("Data") @@ -596,6 +656,9 @@ namespace IdentityServerHost.Migrations b.Property("Expiration"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("Id"); b.Property("SubjectId") @@ -629,6 +692,8 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp"); + b.Property("Description") .HasMaxLength(1000); @@ -639,6 +704,9 @@ namespace IdentityServerHost.Migrations b.Property("Enabled"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("Name") .IsRequired() .HasMaxLength(200); diff --git a/templates/service/host/IdentityServerHost/Migrations/20181031075019_Initial.cs b/templates/service/host/IdentityServerHost/Migrations/20181212121034_Initial.cs similarity index 63% rename from templates/service/host/IdentityServerHost/Migrations/20181031075019_Initial.cs rename to templates/service/host/IdentityServerHost/Migrations/20181212121034_Initial.cs index 106f351d90..cab668b256 100644 --- a/templates/service/host/IdentityServerHost/Migrations/20181031075019_Initial.cs +++ b/templates/service/host/IdentityServerHost/Migrations/20181212121034_Initial.cs @@ -7,11 +7,88 @@ namespace IdentityServerHost.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), + Name = table.Column(maxLength: 256, nullable: false), + Required = table.Column(nullable: false), + IsStatic = table.Column(nullable: false), + Regex = table.Column(maxLength: 512, nullable: true), + RegexDescription = table.Column(maxLength: 128, nullable: true), + Description = table.Column(maxLength: 256, nullable: true), + ValueType = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), + TenantId = table.Column(nullable: true), + Name = table.Column(maxLength: 256, nullable: false), + NormalizedName = table.Column(maxLength: 256, nullable: false), + IsDefault = table.Column(nullable: false), + IsStatic = table.Column(nullable: false), + IsPublic = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 256, nullable: false), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + UserName = table.Column(maxLength: 256, nullable: false), + NormalizedUserName = table.Column(maxLength: 256, nullable: false), + Name = table.Column(maxLength: 64, nullable: true), + Surname = table.Column(maxLength: 64, nullable: true), + Email = table.Column(maxLength: 256, nullable: true), + NormalizedEmail = table.Column(maxLength: 256, nullable: true), + EmailConfirmed = table.Column(nullable: false, defaultValue: false), + PasswordHash = table.Column(maxLength: 256, nullable: true), + SecurityStamp = table.Column(maxLength: 256, nullable: false), + PhoneNumber = table.Column(maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(nullable: false, defaultValue: false), + TwoFactorEnabled = table.Column(nullable: false, defaultValue: false), + LockoutEnd = table.Column(nullable: true), + LockoutEnabled = table.Column(nullable: false, defaultValue: false), + AccessFailedCount = table.Column(nullable: false, defaultValue: 0) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "IdentityServerApiResources", columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), Name = table.Column(maxLength: 200, nullable: false), DisplayName = table.Column(maxLength: 200, nullable: true), Description = table.Column(maxLength: 1000, nullable: true), @@ -27,6 +104,8 @@ namespace IdentityServerHost.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), ClientId = table.Column(maxLength: 200, nullable: false), ClientName = table.Column(maxLength: 200, nullable: true), Description = table.Column(maxLength: 1000, nullable: true), @@ -72,6 +151,8 @@ namespace IdentityServerHost.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), Name = table.Column(maxLength: 200, nullable: false), DisplayName = table.Column(maxLength: 200, nullable: true), Description = table.Column(maxLength: 1000, nullable: true), @@ -90,6 +171,8 @@ namespace IdentityServerHost.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), Key = table.Column(maxLength: 200, nullable: false), Type = table.Column(maxLength: 50, nullable: false), SubjectId = table.Column(maxLength: 200, nullable: true), @@ -103,6 +186,115 @@ namespace IdentityServerHost.Migrations table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); }); + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new + { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + ClaimType = table.Column(maxLength: 256, nullable: false), + ClaimValue = table.Column(maxLength: 1024, nullable: true), + RoleId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpRoleClaims_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserClaims", + columns: table => new + { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + ClaimType = table.Column(maxLength: 256, nullable: false), + ClaimValue = table.Column(maxLength: 1024, nullable: true), + UserId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpUserClaims_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserLogins", + columns: table => new + { + TenantId = table.Column(nullable: true), + UserId = table.Column(nullable: false), + LoginProvider = table.Column(maxLength: 64, nullable: false), + ProviderKey = table.Column(maxLength: 196, nullable: false), + ProviderDisplayName = table.Column(maxLength: 128, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); + table.ForeignKey( + name: "FK_AbpUserLogins_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new + { + TenantId = table.Column(nullable: true), + UserId = table.Column(nullable: false), + RoleId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserTokens", + columns: table => new + { + TenantId = table.Column(nullable: true), + UserId = table.Column(nullable: false), + LoginProvider = table.Column(maxLength: 64, nullable: false), + Name = table.Column(maxLength: 128, nullable: false), + Value = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AbpUserTokens_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "IdentityServerApiClaims", columns: table => new @@ -370,6 +562,51 @@ namespace IdentityServerHost.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserClaims_UserId", + table: "AbpUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserLogins_LoginProvider_ProviderKey", + table: "AbpUserLogins", + columns: new[] { "LoginProvider", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserRoles_RoleId_UserId", + table: "AbpUserRoles", + columns: new[] { "RoleId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_Email", + table: "AbpUsers", + column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedEmail", + table: "AbpUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedUserName", + table: "AbpUsers", + column: "NormalizedUserName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_UserName", + table: "AbpUsers", + column: "UserName"); + migrationBuilder.CreateIndex( name: "IX_IdentityServerClientClaims_ClientId", table: "IdentityServerClientClaims", @@ -389,6 +626,24 @@ namespace IdentityServerHost.Migrations protected override void Down(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "AbpClaimTypes"); + + migrationBuilder.DropTable( + name: "AbpRoleClaims"); + + migrationBuilder.DropTable( + name: "AbpUserClaims"); + + migrationBuilder.DropTable( + name: "AbpUserLogins"); + + migrationBuilder.DropTable( + name: "AbpUserRoles"); + + migrationBuilder.DropTable( + name: "AbpUserTokens"); + migrationBuilder.DropTable( name: "IdentityServerApiClaims"); @@ -431,6 +686,12 @@ namespace IdentityServerHost.Migrations migrationBuilder.DropTable( name: "IdentityServerPersistedGrants"); + migrationBuilder.DropTable( + name: "AbpRoles"); + + migrationBuilder.DropTable( + name: "AbpUsers"); + migrationBuilder.DropTable( name: "IdentityServerApiScopes"); diff --git a/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs b/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs index ab3992ccf8..8961166967 100644 --- a/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs +++ b/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs @@ -24,9 +24,18 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + b.Property("Description") .HasMaxLength(256); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("IsStatic"); b.Property("Name") @@ -53,7 +62,23 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnName("IsStatic"); b.Property("Name") .IsRequired() @@ -106,10 +131,19 @@ namespace IdentityServerHost.Migrations .HasDefaultValue(0); b.Property("ConcurrencyStamp") + .IsConcurrencyToken() .IsRequired() .HasColumnName("ConcurrencyStamp") .HasMaxLength(256); + b.Property("CreationTime"); + + b.Property("CreatorId"); + + b.Property("DeleterId"); + + b.Property("DeletionTime"); + b.Property("Email") .HasColumnName("Email") .HasMaxLength(256); @@ -122,6 +156,12 @@ namespace IdentityServerHost.Migrations b.Property("ExtraProperties") .HasColumnName("ExtraProperties"); + b.Property("IsDeleted"); + + b.Property("LastModificationTime"); + + b.Property("LastModifierId"); + b.Property("LockoutEnabled") .ValueGeneratedOnAdd() .HasColumnName("LockoutEnabled") @@ -129,6 +169,10 @@ namespace IdentityServerHost.Migrations b.Property("LockoutEnd"); + b.Property("Name") + .HasColumnName("Name") + .HasMaxLength(64); + b.Property("NormalizedEmail") .HasColumnName("NormalizedEmail") .HasMaxLength(256); @@ -156,6 +200,10 @@ namespace IdentityServerHost.Migrations .HasColumnName("SecurityStamp") .HasMaxLength(256); + b.Property("Surname") + .HasColumnName("Surname") + .HasMaxLength(64); + b.Property("TenantId") .HasColumnName("TenantId"); @@ -267,6 +315,8 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp"); + b.Property("Description") .HasMaxLength(1000); @@ -275,6 +325,9 @@ namespace IdentityServerHost.Migrations b.Property("Enabled"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("Name") .IsRequired() .HasMaxLength(200); @@ -398,6 +451,8 @@ namespace IdentityServerHost.Migrations b.Property("ClientUri") .HasMaxLength(2000); + b.Property("ConcurrencyStamp"); + b.Property("ConsentLifetime"); b.Property("Description") @@ -407,6 +462,9 @@ namespace IdentityServerHost.Migrations b.Property("Enabled"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("FrontChannelLogoutSessionRequired"); b.Property("FrontChannelLogoutUri") @@ -587,6 +645,8 @@ namespace IdentityServerHost.Migrations .IsRequired() .HasMaxLength(200); + b.Property("ConcurrencyStamp"); + b.Property("CreationTime"); b.Property("Data") @@ -594,6 +654,9 @@ namespace IdentityServerHost.Migrations b.Property("Expiration"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("Id"); b.Property("SubjectId") @@ -627,6 +690,8 @@ namespace IdentityServerHost.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ConcurrencyStamp"); + b.Property("Description") .HasMaxLength(1000); @@ -637,6 +702,9 @@ namespace IdentityServerHost.Migrations b.Property("Enabled"); + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + b.Property("Name") .IsRequired() .HasMaxLength(200); diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181030142530_Initial.Designer.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181212121232_Initial.Designer.cs similarity index 99% rename from templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181030142530_Initial.Designer.cs rename to templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181212121232_Initial.Designer.cs index 201b429008..1644e14900 100644 --- a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181030142530_Initial.Designer.cs +++ b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181212121232_Initial.Designer.cs @@ -10,7 +10,7 @@ using MyCompanyName.MyProjectName.Host; namespace MyCompanyName.MyProjectName.Host.Migrations { [DbContext(typeof(DemoAppDbContext))] - [Migration("20181030142530_Initial")] + [Migration("20181212121232_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -42,6 +42,8 @@ namespace MyCompanyName.MyProjectName.Host.Migrations .HasColumnName("Comments") .HasMaxLength(256); + b.Property("ConcurrencyStamp"); + b.Property("Exceptions") .HasColumnName("Exceptions") .HasMaxLength(4000); diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181030142530_Initial.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181212121232_Initial.cs similarity index 99% rename from templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181030142530_Initial.cs rename to templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181212121232_Initial.cs index 268d53bf1b..c191391cc9 100644 --- a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181030142530_Initial.cs +++ b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20181212121232_Initial.cs @@ -12,6 +12,8 @@ namespace MyCompanyName.MyProjectName.Host.Migrations columns: table => new { Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), UserId = table.Column(nullable: true), UserName = table.Column(maxLength: 256, nullable: true), TenantId = table.Column(nullable: true), @@ -26,8 +28,7 @@ namespace MyCompanyName.MyProjectName.Host.Migrations Url = table.Column(maxLength: 256, nullable: true), Exceptions = table.Column(maxLength: 4000, nullable: true), Comments = table.Column(maxLength: 256, nullable: true), - HttpStatusCode = table.Column(nullable: true), - ExtraProperties = table.Column(nullable: true) + HttpStatusCode = table.Column(nullable: true) }, constraints: table => { diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs index a7dbc673c8..69e2cc0ae2 100644 --- a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs +++ b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs @@ -40,6 +40,8 @@ namespace MyCompanyName.MyProjectName.Host.Migrations .HasColumnName("Comments") .HasMaxLength(256); + b.Property("ConcurrencyStamp"); + b.Property("Exceptions") .HasColumnName("Exceptions") .HasMaxLength(4000);