From a740e4a2a5fca51a7e54baccc9d94edaf1681eb4 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 15 May 2019 15:09:57 +0300 Subject: [PATCH] MVC template cleanup & refactor. --- templates/mvc/.gitignore | 2 +- .../MyProjectNameApplicationModule.cs | 5 ++++ .../Permissions/MyProjectNamePermissions.cs | 3 +- .../MyCompanyName.MyProjectName.Domain.csproj | 2 +- .../MyProjectNameDomainModule.cs | 12 ++++---- .../MyProjectNameMigrationsDbContext.cs | 2 ++ ....cs => 20190515120718_Initial.Designer.cs} | 30 +++++++++++++++++-- ...4_Initial.cs => 20190515120718_Initial.cs} | 23 ++++++++++++++ ...ectNameMigrationsDbContextModelSnapshot.cs | 28 ++++++++++++++++- ...me.EntityFrameworkCore.DbMigrations.csproj | 4 --- .../MyProjectNameEntityFrameworkCoreModule.cs | 4 ++- .../MongoDb/MyProjectNameMongoDbContext.cs | 4 ++- 12 files changed, 100 insertions(+), 19 deletions(-) rename templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/{20190402131334_Initial.Designer.cs => 20190515120718_Initial.Designer.cs} (96%) rename templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/{20190402131334_Initial.cs => 20190515120718_Initial.cs} (96%) diff --git a/templates/mvc/.gitignore b/templates/mvc/.gitignore index 1114901d9b..d1f0abf49e 100644 --- a/templates/mvc/.gitignore +++ b/templates/mvc/.gitignore @@ -252,4 +252,4 @@ paket-files/ *.sln.iml # MyProjectName -src/MyCompanyName.MyProjectName.Web/Logs/logs.txt +src/MyCompanyName.MyProjectName.Web/Logs/* diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs index 861076f3e8..e819e08e5b 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs @@ -20,6 +20,11 @@ namespace MyCompanyName.MyProjectName { Configure(options => { + /* use `true` for the `validate` parameter if you want to + * validate the profile on application startup. + * See http://docs.automapper.org/en/stable/Configuration-validation.html for more + * about configuration validation. + */ options.AddProfile(); }); } diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Application/Permissions/MyProjectNamePermissions.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Application/Permissions/MyProjectNamePermissions.cs index 0646692500..4076366645 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Application/Permissions/MyProjectNamePermissions.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Application/Permissions/MyProjectNamePermissions.cs @@ -1,5 +1,4 @@ -using System; -using Volo.Abp.Reflection; +using Volo.Abp.Reflection; namespace MyCompanyName.MyProjectName.Permissions { diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj index c9e416ca66..d86ac81e86 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj @@ -14,7 +14,7 @@ - + diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs index 7484a0c94d..296d62033b 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs @@ -1,5 +1,4 @@ using MyCompanyName.MyProjectName.Localization.MyProjectName; -using Volo.Abp.Auditing; using Volo.Abp.AuditLogging; using Volo.Abp.BackgroundJobs; using Volo.Abp.FeatureManagement; @@ -9,19 +8,20 @@ using Volo.Abp.Localization.Resources.AbpValidation; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; using Volo.Abp.PermissionManagement.Identity; +using Volo.Abp.SettingManagement; using Volo.Abp.TenantManagement; using Volo.Abp.VirtualFileSystem; namespace MyCompanyName.MyProjectName { [DependsOn( + typeof(AbpAuditLoggingDomainModule), + typeof(BackgroundJobsDomainModule), + typeof(AbpFeatureManagementDomainModule), typeof(AbpIdentityDomainModule), typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpAuditingModule), - typeof(BackgroundJobsDomainModule), - typeof(AbpAuditLoggingDomainModule), - typeof(AbpTenantManagementDomainModule), - typeof(AbpFeatureManagementDomainModule) + typeof(AbpSettingManagementDomainModule), + typeof(AbpTenantManagementDomainModule) )] public class MyProjectNameDomainModule : AbpModule { diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs index 446e6b6ba4..0999a3a3f8 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs @@ -2,6 +2,7 @@ using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.BackgroundJobs.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; using Volo.Abp.Identity; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore; @@ -29,6 +30,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore builder.ConfigureBackgroundJobs(); builder.ConfigureAuditLogging(); builder.ConfigureIdentity(); + builder.ConfigureFeatureManagement(); builder.ConfigureTenantManagement(); /* Configure customizations for entities from the modules included */ diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190402131334_Initial.Designer.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190515120718_Initial.Designer.cs similarity index 96% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190402131334_Initial.Designer.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190515120718_Initial.Designer.cs index 4244444813..eb4daeac8f 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190402131334_Initial.Designer.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190515120718_Initial.Designer.cs @@ -10,14 +10,14 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { [DbContext(typeof(MyProjectNameMigrationsDbContext))] - [Migration("20190402131334_Initial")] + [Migration("20190515120718_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -265,6 +265,32 @@ namespace MyCompanyName.MyProjectName.Migrations b.ToTable("AbpBackgroundJobs"); }); + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .HasMaxLength(64); + + b.Property("ProviderName") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpFeatureValues"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => { b.Property("Id") diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190402131334_Initial.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190515120718_Initial.cs similarity index 96% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190402131334_Initial.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190515120718_Initial.cs index dcba749aed..b6be888a8c 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190402131334_Initial.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190515120718_Initial.cs @@ -80,6 +80,21 @@ namespace MyCompanyName.MyProjectName.Migrations table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); }); + migrationBuilder.CreateTable( + name: "AbpFeatureValues", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(maxLength: 128, nullable: false), + Value = table.Column(maxLength: 128, nullable: false), + ProviderName = table.Column(maxLength: 64, nullable: true), + ProviderKey = table.Column(maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); + }); + migrationBuilder.CreateTable( name: "AbpPermissionGrants", columns: table => new @@ -427,6 +442,11 @@ namespace MyCompanyName.MyProjectName.Migrations table: "AbpEntityPropertyChanges", column: "EntityChangeId"); + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", + table: "AbpFeatureValues", + columns: new[] { "Name", "ProviderName", "ProviderKey" }); + migrationBuilder.CreateIndex( name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey", table: "AbpPermissionGrants", @@ -503,6 +523,9 @@ namespace MyCompanyName.MyProjectName.Migrations migrationBuilder.DropTable( name: "AbpEntityPropertyChanges"); + migrationBuilder.DropTable( + name: "AbpFeatureValues"); + migrationBuilder.DropTable( name: "AbpPermissionGrants"); diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs index f6136bdfbd..93e38fbb06 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs @@ -15,7 +15,7 @@ namespace MyCompanyName.MyProjectName.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -263,6 +263,32 @@ namespace MyCompanyName.MyProjectName.Migrations b.ToTable("AbpBackgroundJobs"); }); + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .HasMaxLength(64); + + b.Property("ProviderName") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpFeatureValues"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => { b.Property("Id") diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj index 773870d3de..b38b78dbd2 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj @@ -7,10 +7,6 @@ MyCompanyName.MyProjectName - - - - diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs index 5f9bd98bcf..c6569579db 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs @@ -28,7 +28,9 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore { context.Services.AddAbpDbContext(options => { - //Remove "includeAllEntities: true" to create default repositories only for aggregate roots + /* Remove "includeAllEntities: true" to create + * default repositories only for aggregate roots + */ options.AddDefaultRepositories(includeAllEntities: true); }); } diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs index 95a041809f..b800cd9063 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs @@ -16,7 +16,9 @@ namespace MyCompanyName.MyProjectName.MongoDb modelBuilder.Entity(b => { - b.CollectionName = "AbpUsers"; //Sharing the same collection "AbpUsers" with the IdentityUser + /* Sharing the same "AbpUsers" collection with the Identity module (IdentityUser entity). + */ + b.CollectionName = "AbpUsers"; }); } }