From 57a8240131cd1e45325173d7eec9f5aa0e682a58 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Sun, 26 May 2019 01:32:50 +0300 Subject: [PATCH] Added tenant management module to the demo app of the module template. --- .../DemoAppDbContext.cs | 2 + .../DemoAppModule.cs | 18 +++-- ....cs => 20190525222748_Initial.Designer.cs} | 73 ++++++++++++++++++- ...0_Initial.cs => 20190525222748_Initial.cs} | 52 +++++++++++++ .../DemoAppDbContextModelSnapshot.cs | 71 ++++++++++++++++++ ...MyCompanyName.MyProjectName.DemoApp.csproj | 7 +- 6 files changed, 214 insertions(+), 9 deletions(-) rename templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/{20190525220130_Initial.Designer.cs => 20190525222748_Initial.Designer.cs} (84%) rename templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/{20190525220130_Initial.cs => 20190525222748_Initial.cs} (85%) diff --git a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppDbContext.cs b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppDbContext.cs index 70d778b63d..b6052ad79c 100644 --- a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppDbContext.cs +++ b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppDbContext.cs @@ -4,6 +4,7 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.TenantManagement.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.DemoApp { @@ -22,6 +23,7 @@ namespace MyCompanyName.MyProjectName.DemoApp modelBuilder.ConfigurePermissionManagement(); modelBuilder.ConfigureSettingManagement(); modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureTenantManagement(); modelBuilder.ConfigureMyProjectName(); } } diff --git a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppModule.cs b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppModule.cs index 57a94eef51..5b04cbd7ca 100644 --- a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppModule.cs +++ b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppModule.cs @@ -23,6 +23,9 @@ using Volo.Abp.PermissionManagement; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.Identity; using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.TenantManagement; +using Volo.Abp.TenantManagement.EntityFrameworkCore; +using Volo.Abp.TenantManagement.Web; using Volo.Abp.Threading; using Volo.Abp.VirtualFileSystem; @@ -32,16 +35,19 @@ namespace MyCompanyName.MyProjectName.DemoApp typeof(MyProjectNameWebModule), typeof(MyProjectNameApplicationModule), typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpAutofacModule), typeof(AbpAccountWebModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementApplicationModule), typeof(AbpIdentityWebModule), typeof(AbpIdentityApplicationModule), - typeof(AbpPermissionManagementApplicationModule), + typeof(AbpIdentityEntityFrameworkCoreModule), typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpAutofacModule), + typeof(AbpTenantManagementWebModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule) )] public class DemoAppModule : AbpModule diff --git a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525220130_Initial.Designer.cs b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525222748_Initial.Designer.cs similarity index 84% rename from templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525220130_Initial.Designer.cs rename to templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525222748_Initial.Designer.cs index 9b44629cd2..755119977e 100644 --- a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525220130_Initial.Designer.cs +++ b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525222748_Initial.Designer.cs @@ -10,7 +10,7 @@ using MyCompanyName.MyProjectName.DemoApp; namespace MyCompanyName.MyProjectName.DemoApp.Migrations { [DbContext(typeof(DemoAppDbContext))] - [Migration("20190525220130_Initial")] + [Migration("20190525222748_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -371,6 +371,69 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.ToTable("AbpSettings"); }); + modelBuilder.Entity("Volo.Abp.TenantManagement.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpTenants"); + }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => + { + b.Property("TenantId"); + + b.Property("Name") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => { b.HasOne("Volo.Abp.Identity.IdentityRole") @@ -415,6 +478,14 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade); }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => + { + b.HasOne("Volo.Abp.TenantManagement.Tenant") + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade); + }); #pragma warning restore 612, 618 } } diff --git a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525220130_Initial.cs b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525222748_Initial.cs similarity index 85% rename from templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525220130_Initial.cs rename to templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525222748_Initial.cs index 53361cc99e..5f6a58f0d0 100644 --- a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525220130_Initial.cs +++ b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190525222748_Initial.cs @@ -76,6 +76,27 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations table.PrimaryKey("PK_AbpSettings", x => x.Id); }); + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), + 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, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + Name = table.Column(maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + }); + migrationBuilder.CreateTable( name: "AbpUsers", columns: table => new @@ -133,6 +154,25 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "AbpTenantConnectionStrings", + columns: table => new + { + TenantId = table.Column(nullable: false), + Name = table.Column(maxLength: 64, nullable: false), + Value = table.Column(maxLength: 1024, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); + table.ForeignKey( + name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", + column: x => x.TenantId, + principalTable: "AbpTenants", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "AbpUserClaims", columns: table => new @@ -241,6 +281,12 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations table: "AbpSettings", columns: new[] { "Name", "ProviderName", "ProviderKey" }); + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name", + unique: true); + migrationBuilder.CreateIndex( name: "IX_AbpUserClaims_UserId", table: "AbpUserClaims", @@ -291,6 +337,9 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations migrationBuilder.DropTable( name: "AbpSettings"); + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); + migrationBuilder.DropTable( name: "AbpUserClaims"); @@ -303,6 +352,9 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations migrationBuilder.DropTable( name: "AbpUserTokens"); + migrationBuilder.DropTable( + name: "AbpTenants"); + migrationBuilder.DropTable( name: "AbpRoles"); diff --git a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs index f15acecaef..aa7a96db9b 100644 --- a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs +++ b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs @@ -369,6 +369,69 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations b.ToTable("AbpSettings"); }); + modelBuilder.Entity("Volo.Abp.TenantManagement.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpTenants"); + }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => + { + b.Property("TenantId"); + + b.Property("Name") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => { b.HasOne("Volo.Abp.Identity.IdentityRole") @@ -413,6 +476,14 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade); }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => + { + b.HasOne("Volo.Abp.TenantManagement.Tenant") + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade); + }); #pragma warning restore 612, 618 } } diff --git a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj index 9839768deb..66b934916e 100644 --- a/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj +++ b/templates/mvc-module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj @@ -13,13 +13,16 @@ + - - + + + +