From d1d9c47cdec4ca7efd25103d9456b8a636bd9dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Sun, 21 Nov 2021 23:52:40 +0300 Subject: [PATCH] use file-scoped namespacing for module template --- ...yProjectNameBlazorHostAutoMapperProfile.cs | 11 +- ...yProjectNameBlazorHostBundleContributor.cs | 17 +- .../MyProjectNameBlazorHostModule.cs | 127 +- .../MyProjectNameHostBrandingProvider.cs | 9 +- .../MyProjectNameHostMenuContributor.cs | 51 +- .../Program.cs | 25 +- .../EntityFrameworkCore/UnifiedDbContext.cs | 33 +- .../UnifiedDbContextFactory.cs | 31 +- .../Menus/MyProjectNameMenuContributor.cs | 43 +- .../Menus/MyProjectNameMenus.cs | 11 +- .../Migrations/20211105130007_Initial.cs | 1391 +++++---- .../MyProjectNameBlazorHostModule.cs | 333 ++- .../MyProjectNameBrandingProvider.cs | 11 +- .../MyProjectNameComponentBase.cs | 11 +- .../Pages/Index.razor.cs | 7 +- .../Program.cs | 65 +- .../Startup.cs | 19 +- .../MultiTenancy/MultiTenancyConsts.cs | 15 +- .../Controllers/HomeController.cs | 11 +- ...ojectNameHttpApiHostMigrationsDbContext.cs | 21 +- ...meHttpApiHostMigrationsDbContextFactory.cs | 31 +- .../MyProjectNameHttpApiHostModule.cs | 271 +- .../Program.cs | 63 +- .../Startup.cs | 19 +- .../IdentityServerHostMigrationsDbContext.cs | 33 +- ...ityServerHostMigrationsDbContextFactory.cs | 31 +- .../IdentityServerDataSeedContributor.cs | 469 ++- .../Migrations/20211105130012_Initial.cs | 2528 ++++++++--------- .../MyProjectNameIdentityServerModule.cs | 325 ++- .../Pages/Index.cshtml.cs | 11 +- .../Program.cs | 63 +- .../Startup.cs | 19 +- .../Controllers/AccountController.cs | 7 +- .../MyProjectNameBrandingProvider.cs | 11 +- .../MyProjectNameWebAutoMapperProfile.cs | 11 +- .../MyProjectNameWebHostMenuContributor.cs | 69 +- .../MyProjectNameWebHostModule.cs | 337 ++- .../Pages/Index.cshtml.cs | 21 +- .../Pages/MyProjectNamePageModel.cs | 13 +- .../Program.cs | 63 +- .../Startup.cs | 19 +- .../EntityFrameworkCore/UnifiedDbContext.cs | 33 +- .../UnifiedDbContextFactory.cs | 31 +- .../Migrations/20211105130018_Initial.cs | 1391 +++++---- .../MyProjectNameWebUnifiedModule.cs | 247 +- .../Pages/Index.cshtml.cs | 11 +- .../Program.cs | 67 +- .../Startup.cs | 19 +- ...MyProjectNameApplicationContractsModule.cs | 17 +- .../MyProjectNameRemoteServiceConsts.cs | 11 +- ...ProjectNamePermissionDefinitionProvider.cs | 21 +- .../Permissions/MyProjectNamePermissions.cs | 17 +- .../Samples/ISampleAppService.cs | 11 +- .../Samples/SampleDto.cs | 11 +- .../MyProjectNameAppService.cs | 13 +- ...ProjectNameApplicationAutoMapperProfile.cs | 17 +- .../MyProjectNameApplicationModule.cs | 29 +- .../Samples/SampleAppService.cs | 43 +- .../MyProjectNameBlazorServerModule.cs | 19 +- .../MyProjectNameBlazorWebAssemblyModule.cs | 21 +- .../Menus/MyProjectNameMenuContributor.cs | 29 +- .../Menus/MyProjectNameMenus.cs | 15 +- .../MyProjectNameBlazorAutoMapperProfile.cs | 17 +- .../MyProjectNameBlazorModule.cs | 47 +- .../Localization/MyProjectNameResource.cs | 11 +- .../MyProjectNameDomainSharedModule.cs | 43 +- .../MyProjectNameErrorCodes.cs | 9 +- .../MyProjectNameDbProperties.cs | 13 +- .../MyProjectNameDomainModule.cs | 15 +- .../MyProjectNameSettingDefinitionProvider.cs | 17 +- .../Settings/MyProjectNameSettings.cs | 17 +- .../IMyProjectNameDbContext.cs | 17 +- .../MyProjectNameDbContext.cs | 33 +- ...ectNameDbContextModelCreatingExtensions.cs | 41 +- .../MyProjectNameEntityFrameworkCoreModule.cs | 23 +- .../MyProjectNameHttpApiClientModule.cs | 31 +- .../MyProjectNameController.cs | 11 +- .../MyProjectNameHttpApiModule.cs | 37 +- .../Samples/SampleController.cs | 45 +- .../MyProjectNameInstallerModule.cs | 23 +- .../MyProjectNameInstallerPipelineBuilder.cs | 15 +- .../MongoDB/IMyProjectNameMongoDbContext.cs | 15 +- .../MongoDB/MyProjectNameMongoDbContext.cs | 25 +- .../MyProjectNameMongoDbContextExtensions.cs | 13 +- .../MongoDB/MyProjectNameMongoDbModule.cs | 21 +- .../Menus/MyProjectNameMenuContributor.cs | 27 +- .../Menus/MyProjectNameMenus.cs | 15 +- .../MyProjectNameWebAutoMapperProfile.cs | 17 +- .../MyProjectNameWebModule.cs | 67 +- .../Pages/MyProjectName/Index.cshtml.cs | 11 +- .../Pages/MyProjectNamePageModel.cs | 19 +- .../MyProjectNameApplicationTestBase.cs | 15 +- .../MyProjectNameApplicationTestModule.cs | 15 +- .../Samples/SampleAppService_Tests.cs | 39 +- .../MyProjectNameDomainTestBase.cs | 15 +- .../MyProjectNameDomainTestModule.cs | 23 +- .../Samples/SampleManager_Tests.cs | 23 +- ...yProjectNameEntityFrameworkCoreTestBase.cs | 15 +- ...rojectNameEntityFrameworkCoreTestModule.cs | 53 +- .../Samples/SampleRepository_Tests.cs | 15 +- .../ClientDemoService.cs | 247 +- .../ConsoleTestAppHostedService.cs | 41 +- .../MyProjectNameConsoleApiClientModule.cs | 17 +- .../Program.cs | 27 +- .../MongoDB/MongoDbFixture.cs | 27 +- .../MongoDB/MongoTestCollection.cs | 13 +- .../MongoDB/MyProjectNameMongoDbTestBase.cs | 15 +- .../MongoDB/MyProjectNameMongoDbTestModule.cs | 33 +- .../MongoDB/Samples/SampleRepository_Tests.cs | 17 +- .../MyProjectNameDataSeedContributor.cs | 37 +- .../MyProjectNameTestBase.cs | 69 +- .../MyProjectNameTestBaseModule.cs | 51 +- .../Samples/SampleRepository_Tests.cs | 33 +- .../Security/FakeCurrentPrincipalAccessor.cs | 45 +- 114 files changed, 5053 insertions(+), 5256 deletions(-) diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostAutoMapperProfile.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostAutoMapperProfile.cs index 7135b52c32..cd97f500ad 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostAutoMapperProfile.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostAutoMapperProfile.cs @@ -1,12 +1,11 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName.Blazor.Host +namespace MyCompanyName.MyProjectName.Blazor.Host; + +public class MyProjectNameBlazorHostAutoMapperProfile : Profile { - public class MyProjectNameBlazorHostAutoMapperProfile : Profile + public MyProjectNameBlazorHostAutoMapperProfile() { - public MyProjectNameBlazorHostAutoMapperProfile() - { - //Define your AutoMapper configuration here for the Blazor project. - } + //Define your AutoMapper configuration here for the Blazor project. } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostBundleContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostBundleContributor.cs index ff1ae18652..bae98f08ea 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostBundleContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostBundleContributor.cs @@ -1,17 +1,16 @@ using Volo.Abp.Bundling; -namespace MyCompanyName.MyProjectName.Blazor.Host +namespace MyCompanyName.MyProjectName.Blazor.Host; + +public class MyProjectNameBlazorHostBundleContributor : IBundleContributor { - public class MyProjectNameBlazorHostBundleContributor : IBundleContributor + public void AddScripts(BundleContext context) { - public void AddScripts(BundleContext context) - { - } + } - public void AddStyles(BundleContext context) - { - context.Add("main.css", true); - } + public void AddStyles(BundleContext context) + { + context.Add("main.css", true); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostModule.cs index bcca2adf3a..5ec65f694e 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostModule.cs @@ -18,84 +18,83 @@ using Volo.Abp.SettingManagement.Blazor.WebAssembly; using Volo.Abp.TenantManagement.Blazor.WebAssembly; using Volo.Abp.UI.Navigation; -namespace MyCompanyName.MyProjectName.Blazor.Host +namespace MyCompanyName.MyProjectName.Blazor.Host; + +[DependsOn( + typeof(AbpAutofacWebAssemblyModule), + typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule), + typeof(AbpAccountApplicationContractsModule), + typeof(AbpIdentityBlazorWebAssemblyModule), + typeof(AbpTenantManagementBlazorWebAssemblyModule), + typeof(AbpSettingManagementBlazorWebAssemblyModule), + typeof(MyProjectNameBlazorWebAssemblyModule) +)] +public class MyProjectNameBlazorHostModule : AbpModule { - [DependsOn( - typeof(AbpAutofacWebAssemblyModule), - typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule), - typeof(AbpAccountApplicationContractsModule), - typeof(AbpIdentityBlazorWebAssemblyModule), - typeof(AbpTenantManagementBlazorWebAssemblyModule), - typeof(AbpSettingManagementBlazorWebAssemblyModule), - typeof(MyProjectNameBlazorWebAssemblyModule) - )] - public class MyProjectNameBlazorHostModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var environment = context.Services.GetSingletonInstance(); - var builder = context.Services.GetSingletonInstance(); + var environment = context.Services.GetSingletonInstance(); + var builder = context.Services.GetSingletonInstance(); - ConfigureAuthentication(builder); - ConfigureHttpClient(context, environment); - ConfigureBlazorise(context); - ConfigureRouter(context); - ConfigureUI(builder); - ConfigureMenu(context); - ConfigureAutoMapper(context); - } + ConfigureAuthentication(builder); + ConfigureHttpClient(context, environment); + ConfigureBlazorise(context); + ConfigureRouter(context); + ConfigureUI(builder); + ConfigureMenu(context); + ConfigureAutoMapper(context); + } - private void ConfigureRouter(ServiceConfigurationContext context) + private void ConfigureRouter(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly; - }); - } + options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly; + }); + } - private void ConfigureMenu(ServiceConfigurationContext context) + private void ConfigureMenu(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameHostMenuContributor(context.Services.GetConfiguration())); - }); - } + options.MenuContributors.Add(new MyProjectNameHostMenuContributor(context.Services.GetConfiguration())); + }); + } - private void ConfigureBlazorise(ServiceConfigurationContext context) - { - context.Services - .AddBootstrap5Providers() - .AddFontAwesomeIcons(); - } + private void ConfigureBlazorise(ServiceConfigurationContext context) + { + context.Services + .AddBootstrap5Providers() + .AddFontAwesomeIcons(); + } - private static void ConfigureAuthentication(WebAssemblyHostBuilder builder) + private static void ConfigureAuthentication(WebAssemblyHostBuilder builder) + { + builder.Services.AddOidcAuthentication(options => { - builder.Services.AddOidcAuthentication(options => - { - builder.Configuration.Bind("AuthServer", options.ProviderOptions); - options.ProviderOptions.DefaultScopes.Add("MyProjectName"); - }); - } + builder.Configuration.Bind("AuthServer", options.ProviderOptions); + options.ProviderOptions.DefaultScopes.Add("MyProjectName"); + }); + } - private static void ConfigureUI(WebAssemblyHostBuilder builder) - { - builder.RootComponents.Add("#ApplicationContainer"); - } + private static void ConfigureUI(WebAssemblyHostBuilder builder) + { + builder.RootComponents.Add("#ApplicationContainer"); + } - private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment) + private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment) + { + context.Services.AddTransient(sp => new HttpClient { - context.Services.AddTransient(sp => new HttpClient - { - BaseAddress = new Uri(environment.BaseAddress) - }); - } + BaseAddress = new Uri(environment.BaseAddress) + }); + } - private void ConfigureAutoMapper(ServiceConfigurationContext context) + private void ConfigureAutoMapper(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.AddMaps(); - }); - } + options.AddMaps(); + }); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostBrandingProvider.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostBrandingProvider.cs index 13c921dea7..4f171cb8af 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostBrandingProvider.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostBrandingProvider.cs @@ -1,9 +1,8 @@ using Volo.Abp.Ui.Branding; -namespace MyCompanyName.MyProjectName.Blazor.Host +namespace MyCompanyName.MyProjectName.Blazor.Host; + +public class MyProjectNameHostBrandingProvider : DefaultBrandingProvider { - public class MyProjectNameHostBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostMenuContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostMenuContributor.cs index 77a081bd74..c2527a0371 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostMenuContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostMenuContributor.cs @@ -4,40 +4,39 @@ using Microsoft.Extensions.Configuration; using Volo.Abp.Authorization.Permissions; using Volo.Abp.UI.Navigation; using Volo.Abp.Account.Localization; -namespace MyCompanyName.MyProjectName.Blazor.Host +namespace MyCompanyName.MyProjectName.Blazor.Host; + +public class MyProjectNameHostMenuContributor : IMenuContributor { - public class MyProjectNameHostMenuContributor : IMenuContributor - { - private readonly IConfiguration _configuration; + private readonly IConfiguration _configuration; - public MyProjectNameHostMenuContributor(IConfiguration configuration) - { - _configuration = configuration; - } + public MyProjectNameHostMenuContributor(IConfiguration configuration) + { + _configuration = configuration; + } - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + public async Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name == StandardMenus.User) { - if (context.Menu.Name == StandardMenus.User) - { - await ConfigureUserMenuAsync(context); - } + await ConfigureUserMenuAsync(context); } + } - private Task ConfigureUserMenuAsync(MenuConfigurationContext context) - { - var accountStringLocalizer = context.GetLocalizer(); + private Task ConfigureUserMenuAsync(MenuConfigurationContext context) + { + var accountStringLocalizer = context.GetLocalizer(); - var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; + var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; - context.Menu.AddItem(new ApplicationMenuItem( - "Account.Manage", - accountStringLocalizer["ManageYourProfile"], - $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", - icon: "fa fa-cog", - order: 1000, - null).RequireAuthenticated()); + context.Menu.AddItem(new ApplicationMenuItem( + "Account.Manage", + accountStringLocalizer["ManageYourProfile"], + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", + icon: "fa fa-cog", + order: 1000, + null).RequireAuthenticated()); - return Task.CompletedTask; - } + return Task.CompletedTask; } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/Program.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/Program.cs index 6712a8fc5e..d5b3c36ff5 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/Program.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/Program.cs @@ -1,24 +1,23 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -namespace MyCompanyName.MyProjectName.Blazor.Host +namespace MyCompanyName.MyProjectName.Blazor.Host; + +public class Program { - public class Program + public static async Task Main(string[] args) { - public static async Task Main(string[] args) - { - var builder = WebAssemblyHostBuilder.CreateDefault(args); + var builder = WebAssemblyHostBuilder.CreateDefault(args); - var application = builder.AddApplication(options => - { - options.UseAutofac(); - }); + var application = builder.AddApplication(options => + { + options.UseAutofac(); + }); - var host = builder.Build(); + var host = builder.Build(); - await application.InitializeAsync(host.Services); + await application.InitializeAsync(host.Services); - await host.RunAsync(); - } + await host.RunAsync(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContext.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContext.cs index ac1f756c45..987239abe0 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContext.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContext.cs @@ -8,27 +8,26 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore; + +public class UnifiedDbContext : AbpDbContext { - public class UnifiedDbContext : AbpDbContext + public UnifiedDbContext(DbContextOptions options) + : base(options) { - public UnifiedDbContext(DbContextOptions options) - : base(options) - { - } + } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); - modelBuilder.ConfigurePermissionManagement(); - modelBuilder.ConfigureSettingManagement(); - modelBuilder.ConfigureAuditLogging(); - modelBuilder.ConfigureIdentity(); - modelBuilder.ConfigureFeatureManagement(); - modelBuilder.ConfigureTenantManagement(); - modelBuilder.ConfigureMyProjectName(); - } + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigureAuditLogging(); + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureFeatureManagement(); + modelBuilder.ConfigureTenantManagement(); + modelBuilder.ConfigureMyProjectName(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContextFactory.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContextFactory.cs index cddc6f20c1..2f2d8a79cc 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContextFactory.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContextFactory.cs @@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore; + +public class UnifiedDbContextFactory : IDesignTimeDbContextFactory { - public class UnifiedDbContextFactory : IDesignTimeDbContextFactory + public UnifiedDbContext CreateDbContext(string[] args) { - public UnifiedDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); - return new UnifiedDbContext(builder.Options); - } + return new UnifiedDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenuContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenuContributor.cs index a9a6e6e522..50b2e293d3 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenuContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenuContributor.cs @@ -5,35 +5,34 @@ using Volo.Abp.SettingManagement.Blazor.Menus; using Volo.Abp.TenantManagement.Blazor.Navigation; using Volo.Abp.UI.Navigation; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus +namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus; + +public class MyProjectNameMenuContributor : IMenuContributor { - public class MyProjectNameMenuContributor : IMenuContributor + public async Task ConfigureMenuAsync(MenuConfigurationContext context) { - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + if (context.Menu.Name == StandardMenus.Main) { - if (context.Menu.Name == StandardMenus.Main) - { - await ConfigureMainMenuAsync(context); - } + await ConfigureMainMenuAsync(context); } + } - private Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - var administration = context.Menu.GetAdministration(); + private Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + var administration = context.Menu.GetAdministration(); - if (MultiTenancyConsts.IsEnabled) - { - administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); - } - else - { - administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); - } + if (MultiTenancyConsts.IsEnabled) + { + administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); + } + else + { + administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); + } - administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); - administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); + administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); + administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); - return Task.CompletedTask; - } + return Task.CompletedTask; } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenus.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenus.cs index 568dff3a68..dc5b32b2a5 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenus.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenus.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus +namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus; + +public class MyProjectNameMenus { - public class MyProjectNameMenus - { - private const string Prefix = "MyProjectName"; + private const string Prefix = "MyProjectName"; - //Add your menu items here... + //Add your menu items here... - } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20211105130007_Initial.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20211105130007_Initial.cs index c0357b760b..471b4ec322 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20211105130007_Initial.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20211105130007_Initial.cs @@ -3,732 +3,709 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Migrations +namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Migrations; + +public partial class Initial : Migration { - public partial class Initial : Migration + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AbpAuditLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + TenantName = table.Column(type: "nvarchar(max)", nullable: true), + ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), + ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Exceptions = table.Column(type: "nvarchar(max)", nullable: true), + Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + HttpStatusCode = table.Column(type: "int", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Required = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ValueType = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpFeatureValues", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpLinkUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), + SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), + TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), + TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), + DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsDefault = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + IsPublic = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSecurityLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + IsActive = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpAuditLogActions", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); + table.ForeignKey( + name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ChangeTime = table.Column(type: "datetime2", nullable: false), + ChangeType = table.Column(type: "tinyint", nullable: false), + EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new { + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + 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: "AbpTenantConnectionStrings", + columns: table => new { + TenantId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Value = table.Column(type: "nvarchar(1024)", 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 { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + 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 { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(128)", 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: "AbpUserOrganizationUnits", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + 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 { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Value = table.Column(type: "nvarchar(max)", 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: "AbpEntityPropertyChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), + NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", + column: x => x.EntityChangeId, + principalTable: "AbpEntityChanges", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_AuditLogId", + table: "AbpAuditLogActions", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", + table: "AbpAuditLogActions", + columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "UserId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_AuditLogId", + table: "AbpEntityChanges", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", + table: "AbpEntityChanges", + columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityPropertyChanges_EntityChangeId", + table: "AbpEntityPropertyChanges", + column: "EntityChangeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", + table: "AbpFeatureValues", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", + table: "AbpLinkUsers", + columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, + unique: true, + filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[TenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Action", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Action" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_ApplicationName", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "ApplicationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Identity", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Identity" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_UserId", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name"); + + 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_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + 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) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpAuditLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - TenantName = table.Column(type: "nvarchar(max)", nullable: true), - ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), - ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Exceptions = table.Column(type: "nvarchar(max)", nullable: true), - Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - HttpStatusCode = table.Column(type: "int", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpClaimTypes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Required = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ValueType = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpFeatureValues", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpLinkUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), - SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), - TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), - TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnits", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), - DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); - table.ForeignKey( - name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", - column: x => x.ParentId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "AbpPermissionGrants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoles", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsDefault = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - IsPublic = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSecurityLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSettings", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSettings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpTenants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), - PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - IsActive = table.Column(type: "bit", nullable: false), - TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), - LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpAuditLogActions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); - table.ForeignKey( - name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ChangeTime = table.Column(type: "datetime2", nullable: false), - ChangeType = table.Column(type: "tinyint", nullable: false), - EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnitRoles", - columns: table => new - { - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpRoleClaims", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - 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: "AbpTenantConnectionStrings", - columns: table => new - { - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Value = table.Column(type: "nvarchar(1024)", 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 - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - 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 - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), - ProviderDisplayName = table.Column(type: "nvarchar(128)", 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: "AbpUserOrganizationUnits", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserRoles", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - 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 - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Value = table.Column(type: "nvarchar(max)", 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: "AbpEntityPropertyChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), - NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", - column: x => x.EntityChangeId, - principalTable: "AbpEntityChanges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_AuditLogId", - table: "AbpAuditLogActions", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", - table: "AbpAuditLogActions", - columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "UserId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_AuditLogId", - table: "AbpEntityChanges", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", - table: "AbpEntityChanges", - columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityPropertyChanges_EntityChangeId", - table: "AbpEntityPropertyChanges", - column: "EntityChangeId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", - table: "AbpFeatureValues", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", - table: "AbpLinkUsers", - columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, - unique: true, - filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", - table: "AbpOrganizationUnitRoles", - columns: new[] { "RoleId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_Code", - table: "AbpOrganizationUnits", - column: "Code"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_ParentId", - table: "AbpOrganizationUnits", - column: "ParentId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", - table: "AbpPermissionGrants", - columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[TenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoleClaims_RoleId", - table: "AbpRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoles_NormalizedName", - table: "AbpRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Action", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Action" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_ApplicationName", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "ApplicationName" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Identity", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Identity" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_UserId", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSettings_Name_ProviderName_ProviderKey", - table: "AbpSettings", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpTenants_Name", - table: "AbpTenants", - column: "Name"); - - 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_AbpUserOrganizationUnits_UserId_OrganizationUnitId", - table: "AbpUserOrganizationUnits", - columns: new[] { "UserId", "OrganizationUnitId" }); - - 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: "AbpAuditLogActions"); - - migrationBuilder.DropTable( - name: "AbpClaimTypes"); - - migrationBuilder.DropTable( - name: "AbpEntityPropertyChanges"); - - migrationBuilder.DropTable( - name: "AbpFeatureValues"); + migrationBuilder.DropTable( + name: "AbpAuditLogActions"); + + migrationBuilder.DropTable( + name: "AbpClaimTypes"); + + migrationBuilder.DropTable( + name: "AbpEntityPropertyChanges"); + + migrationBuilder.DropTable( + name: "AbpFeatureValues"); - migrationBuilder.DropTable( - name: "AbpLinkUsers"); + migrationBuilder.DropTable( + name: "AbpLinkUsers"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnitRoles"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); - migrationBuilder.DropTable( - name: "AbpPermissionGrants"); + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); - migrationBuilder.DropTable( - name: "AbpRoleClaims"); + migrationBuilder.DropTable( + name: "AbpRoleClaims"); - migrationBuilder.DropTable( - name: "AbpSecurityLogs"); + migrationBuilder.DropTable( + name: "AbpSecurityLogs"); - migrationBuilder.DropTable( - name: "AbpSettings"); + migrationBuilder.DropTable( + name: "AbpSettings"); - migrationBuilder.DropTable( - name: "AbpTenantConnectionStrings"); + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); - migrationBuilder.DropTable( - name: "AbpUserClaims"); + migrationBuilder.DropTable( + name: "AbpUserClaims"); - migrationBuilder.DropTable( - name: "AbpUserLogins"); + migrationBuilder.DropTable( + name: "AbpUserLogins"); - migrationBuilder.DropTable( - name: "AbpUserOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpUserRoles"); + migrationBuilder.DropTable( + name: "AbpUserRoles"); - migrationBuilder.DropTable( - name: "AbpUserTokens"); + migrationBuilder.DropTable( + name: "AbpUserTokens"); - migrationBuilder.DropTable( - name: "AbpEntityChanges"); + migrationBuilder.DropTable( + name: "AbpEntityChanges"); - migrationBuilder.DropTable( - name: "AbpTenants"); + migrationBuilder.DropTable( + name: "AbpTenants"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpRoles"); + migrationBuilder.DropTable( + name: "AbpRoles"); - migrationBuilder.DropTable( - name: "AbpUsers"); + migrationBuilder.DropTable( + name: "AbpUsers"); - migrationBuilder.DropTable( - name: "AbpAuditLogs"); - } + migrationBuilder.DropTable( + name: "AbpAuditLogs"); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBlazorHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBlazorHostModule.cs index b21ec32c87..f5d140a6c8 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBlazorHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBlazorHostModule.cs @@ -50,208 +50,207 @@ using Volo.Abp.Threading; using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host +namespace MyCompanyName.MyProjectName.Blazor.Server.Host; + +[DependsOn( + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameHttpApiModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAutofacModule), + typeof(AbpSwashbuckleModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpAccountApplicationModule), + typeof(AbpAspNetCoreComponentsServerBasicThemeModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpIdentityBlazorServerModule), + typeof(AbpFeatureManagementApplicationModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpTenantManagementBlazorServerModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpSettingManagementBlazorServerModule), + typeof(AbpSettingManagementApplicationModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(MyProjectNameBlazorServerModule) +)] +public class MyProjectNameBlazorHostModule : AbpModule { - [DependsOn( - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameHttpApiModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAutofacModule), - typeof(AbpSwashbuckleModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAccountApplicationModule), - typeof(AbpAspNetCoreComponentsServerBasicThemeModule), - typeof(AbpIdentityApplicationModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpIdentityBlazorServerModule), - typeof(AbpFeatureManagementApplicationModule), - typeof(AbpFeatureManagementEntityFrameworkCoreModule), - typeof(AbpTenantManagementBlazorServerModule), - typeof(AbpTenantManagementApplicationModule), - typeof(AbpTenantManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpSettingManagementBlazorServerModule), - typeof(AbpSettingManagementApplicationModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(MyProjectNameBlazorServerModule) - )] - public class MyProjectNameBlazorHostModule: AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(MyProjectNameResource), - typeof(MyProjectNameDomainModule).Assembly, - typeof(MyProjectNameDomainSharedModule).Assembly, - typeof(MyProjectNameApplicationModule).Assembly, - typeof(MyProjectNameApplicationContractsModule).Assembly, - typeof(MyProjectNameBlazorHostModule).Assembly - ); - }); - } + options.AddAssemblyResource( + typeof(MyProjectNameResource), + typeof(MyProjectNameDomainModule).Assembly, + typeof(MyProjectNameDomainSharedModule).Assembly, + typeof(MyProjectNameApplicationModule).Assembly, + typeof(MyProjectNameApplicationContractsModule).Assembly, + typeof(MyProjectNameBlazorHostModule).Assembly + ); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) - { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - Configure(options => - { - options.UseSqlServer(); - }); + Configure(options => + { + options.UseSqlServer(); + }); - Configure(options => - { + Configure(options => + { // MVC UI options.StyleBundles.Configure( - BasicThemeBundles.Styles.Global, - bundle => - { - bundle.AddFiles("/global-styles.css"); - } - ); + BasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/global-styles.css"); + } + ); //BLAZOR UI options.StyleBundles.Configure( - BlazorBasicThemeBundles.Styles.Global, - bundle => - { - bundle.AddFiles("/blazor-global-styles.css"); + BlazorBasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/blazor-global-styles.css"); //You can remove the following line if you don't use Blazor CSS isolation for components bundle.AddFiles("/MyCompanyName.MyProjectName.Blazor.Server.Host.styles.css"); - } - ); - }); - - context.Services.AddAuthentication() - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.Audience = "MyProjectName"; - }); + } + ); + }); - if(hostingEnvironment.IsDevelopment()) + context.Services.AddAuthentication() + .AddJwtBearer(options => { - Configure(options => - { - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain.Shared", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); - }); - } - - context.Services.AddAbpSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "MyProjectName"; + }); - Configure(options => + if (hostingEnvironment.IsDevelopment()) + { + Configure(options => { - options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); - options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); - options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); - options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); - options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); - options.Languages.Add(new LanguageInfo("it", "it", "Italian", "it")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)")); - options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); - options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); - options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); - options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); - options.Languages.Add(new LanguageInfo("es", "es", "Español")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain.Shared", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); }); + } - Configure(options => + context.Services.AddAbpSwaggerGen( + options => { - options.IsEnabled = MultiTenancyConsts.IsEnabled; + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - context.Services - .AddBootstrap5Providers() - .AddFontAwesomeIcons(); + Configure(options => + { + options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); + options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); + options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); + options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); + options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); + options.Languages.Add(new LanguageInfo("it", "it", "Italian", "it")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)")); + options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); + options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); + options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); + options.Languages.Add(new LanguageInfo("es", "es", "Español")); + }); - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor()); - }); + Configure(options => + { + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); - Configure(options => - { - options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly; - }); + context.Services + .AddBootstrap5Providers() + .AddFontAwesomeIcons(); + + Configure(options => + { + options.MenuContributors.Add(new MyProjectNameMenuContributor()); + }); + + Configure(options => + { + options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly; + }); #if DEBUG - context.Services.Replace(ServiceDescriptor.Singleton()); + context.Services.Replace(ServiceDescriptor.Singleton()); #endif - } + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - var env = context.GetEnvironment(); - var app = context.GetApplicationBuilder(); + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var env = context.GetEnvironment(); + var app = context.GetApplicationBuilder(); - app.UseAbpRequestLocalization(); + app.UseAbpRequestLocalization(); - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Error"); - app.UseHsts(); - } + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Error"); + app.UseHsts(); + } - app.UseHttpsRedirection(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); - app.UseJwtTokenMiddleware(); + app.UseHttpsRedirection(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); + app.UseJwtTokenMiddleware(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - app.UseUnitOfWork(); - app.UseIdentityServer(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); - }); - app.UseConfiguredEndpoints(); + app.UseUnitOfWork(); + app.UseIdentityServer(); + app.UseAuthorization(); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); + }); + app.UseConfiguredEndpoints(); - using (var scope = context.ServiceProvider.CreateScope()) + using (var scope = context.ServiceProvider.CreateScope()) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + }); } } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBrandingProvider.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBrandingProvider.cs index 737a73fe89..3c4df040d6 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBrandingProvider.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Ui.Branding; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host +namespace MyCompanyName.MyProjectName.Blazor.Server.Host; + +[Dependency(ReplaceServices = true)] +public class MyProjectNameBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class MyProjectNameBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameComponentBase.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameComponentBase.cs index 8189eab653..b6b5388888 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameComponentBase.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameComponentBase.cs @@ -1,13 +1,12 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Components; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host +namespace MyCompanyName.MyProjectName.Blazor.Server.Host; + +public abstract class MyProjectNameComponentBase : AbpComponentBase { - public abstract class MyProjectNameComponentBase : AbpComponentBase + protected MyProjectNameComponentBase() { - protected MyProjectNameComponentBase() - { - LocalizationResource = typeof(MyProjectNameResource); - } + LocalizationResource = typeof(MyProjectNameResource); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Pages/Index.razor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Pages/Index.razor.cs index cdda304c8e..3f792ea6c2 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Pages/Index.razor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Pages/Index.razor.cs @@ -1,6 +1,5 @@ -namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Pages +namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Pages; + +public partial class Index { - public partial class Index - { - } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Program.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Program.cs index 14ab96b609..1301cbfb3e 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Program.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Program.cs @@ -5,53 +5,52 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host +namespace MyCompanyName.MyProjectName.Blazor.Server.Host; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) - .Enrich.FromLogContext() - .WriteTo.Async(c => c.File("Logs/logs.txt")) + .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("Logs/logs.txt")) #if DEBUG .WriteTo.Async(c => c.Console()) #endif .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } + } - public static IHostBuilder CreateHostBuilder(string[] args) => - Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { + public static IHostBuilder CreateHostBuilder(string[] args) => + Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); - } + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Startup.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Startup.cs index e309f15d47..d356f6bede 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Startup.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Startup.cs @@ -2,18 +2,17 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; -namespace MyCompanyName.MyProjectName.Blazor.Server.Host +namespace MyCompanyName.MyProjectName.Blazor.Server.Host; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.InitializeApplication(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Host.Shared/MultiTenancy/MultiTenancyConsts.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Host.Shared/MultiTenancy/MultiTenancyConsts.cs index 0c81fd8a49..52e7a02844 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Host.Shared/MultiTenancy/MultiTenancyConsts.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Host.Shared/MultiTenancy/MultiTenancyConsts.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName.MultiTenancy +namespace MyCompanyName.MyProjectName.MultiTenancy; + +public static class MultiTenancyConsts { - public static class MultiTenancyConsts - { - /* Enable/disable multi-tenancy in a single point - * to test your module with multi-tenancy. - */ - public const bool IsEnabled = false; - } + /* Enable/disable multi-tenancy in a single point + * to test your module with multi-tenancy. + */ + public const bool IsEnabled = false; } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs index cebd5b80ee..02a2380214 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs @@ -1,13 +1,12 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; -namespace MyCompanyName.MyProjectName.Controllers +namespace MyCompanyName.MyProjectName.Controllers; + +public class HomeController : AbpController { - public class HomeController : AbpController + public ActionResult Index() { - public ActionResult Index() - { - return Redirect("~/swagger"); - } + return Redirect("~/swagger"); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContext.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContext.cs index 64fa317c51..b6e1e4bd40 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContext.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContext.cs @@ -1,21 +1,20 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class MyProjectNameHttpApiHostMigrationsDbContext : AbpDbContext { - public class MyProjectNameHttpApiHostMigrationsDbContext : AbpDbContext + public MyProjectNameHttpApiHostMigrationsDbContext(DbContextOptions options) + : base(options) { - public MyProjectNameHttpApiHostMigrationsDbContext(DbContextOptions options) - : base(options) - { - } + } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); - modelBuilder.ConfigureMyProjectName(); - } + modelBuilder.ConfigureMyProjectName(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContextFactory.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContextFactory.cs index f396202197..ce6feb9a36 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContextFactory.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContextFactory.cs @@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class MyProjectNameHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory { - public class MyProjectNameHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory + public MyProjectNameHttpApiHostMigrationsDbContext CreateDbContext(string[] args) { - public MyProjectNameHttpApiHostMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("MyProjectName")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("MyProjectName")); - return new MyProjectNameHttpApiHostMigrationsDbContext(builder.Options); - } + return new MyProjectNameHttpApiHostMigrationsDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index 9a11f0cb5f..9550adbb44 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -33,166 +33,165 @@ using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.Swashbuckle; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(MyProjectNameHttpApiModule), + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) + )] +public class MyProjectNameHttpApiHostModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(MyProjectNameHttpApiModule), - typeof(AbpAspNetCoreMvcUiMultiTenancyModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameHttpApiHostModule : AbpModule + + public override void ConfigureServices(ServiceConfigurationContext context) { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); + options.UseSqlServer(); + }); - Configure(options => - { - options.UseSqlServer(); - }); + Configure(options => + { + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); - Configure(options => + if (hostingEnvironment.IsDevelopment()) + { + Configure(options => { - options.IsEnabled = MultiTenancyConsts.IsEnabled; + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain.Shared", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar))); }); + } - if (hostingEnvironment.IsDevelopment()) + context.Services.AddAbpSwaggerGenWithOAuth( + configuration["AuthServer:Authority"], + new Dictionary { - Configure(options => - { - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain.Shared", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar))); - }); - } - - context.Services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], - new Dictionary - { {"MyProjectName", "MyProjectName API"} - }, - options => - { - options.SwaggerDoc("v1", new OpenApiInfo {Title = "MyProjectName API", Version = "v1"}); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); - - Configure(options => + }, + options => { - options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); - options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); - options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); - options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); - options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); - options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); - options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); - options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); - options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); - options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); - options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); - options.Languages.Add(new LanguageInfo("es", "es", "Español")); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.Audience = "MyProjectName"; - }); + Configure(options => + { + options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); + options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); + options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); + options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); + options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); + options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); + options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); + options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); + options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); + options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); + options.Languages.Add(new LanguageInfo("es", "es", "Español")); + }); - Configure(options => + context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => { - options.KeyPrefix = "MyProjectName:"; + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "MyProjectName"; }); - var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); - } + Configure(options => + { + options.KeyPrefix = "MyProjectName:"; + }); - context.Services.AddCors(options => - { - options.AddDefaultPolicy(builder => - { - builder - .WithOrigins( - configuration["App:CorsOrigins"] - .Split(",", StringSplitOptions.RemoveEmptyEntries) - .Select(o => o.RemovePostFix("/")) - .ToArray() - ) - .WithAbpExposedHeaders() - .SetIsOriginAllowedToAllowWildcardSubdomains() - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials(); - }); - }); + var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); + if (!hostingEnvironment.IsDevelopment()) + { + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } - public override void OnApplicationInitialization(ApplicationInitializationContext context) + context.Services.AddCors(options => { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else + options.AddDefaultPolicy(builder => { - app.UseHsts(); - } - - app.UseHttpsRedirection(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseCors(); - app.UseAuthentication(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } - app.UseAbpRequestLocalization(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); - - var configuration = context.GetConfiguration(); - options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); - options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); - options.OAuthScopes("MyProjectName"); + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + }); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseCors(); + app.UseAuthentication(); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } + app.UseAbpRequestLocalization(); + app.UseAuthorization(); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); + + var configuration = context.GetConfiguration(); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + options.OAuthScopes("MyProjectName"); + }); + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs index b2811a98ba..500a2cfc00 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs @@ -6,51 +6,50 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.Async(c => c.File("Logs/logs.txt")) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("Logs/logs.txt")) #if DEBUG .WriteTo.Async(c => c.Console()) #endif .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs index 51efdce5bc..200da6e542 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs @@ -4,18 +4,17 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs index 7e38e00485..3b04ddd4bb 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs @@ -8,27 +8,26 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class IdentityServerHostMigrationsDbContext : AbpDbContext { - public class IdentityServerHostMigrationsDbContext : AbpDbContext + public IdentityServerHostMigrationsDbContext(DbContextOptions options) + : base(options) { - public IdentityServerHostMigrationsDbContext(DbContextOptions options) - : base(options) - { - } + } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); - modelBuilder.ConfigurePermissionManagement(); - modelBuilder.ConfigureSettingManagement(); - modelBuilder.ConfigureAuditLogging(); - modelBuilder.ConfigureIdentity(); - modelBuilder.ConfigureIdentityServer(); - modelBuilder.ConfigureFeatureManagement(); - modelBuilder.ConfigureTenantManagement(); - } + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigureAuditLogging(); + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureIdentityServer(); + modelBuilder.ConfigureFeatureManagement(); + modelBuilder.ConfigureTenantManagement(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs index 4722baae4c..7c24c3fb90 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs @@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class IdentityServerHostMigrationsDbContextFactory : IDesignTimeDbContextFactory { - public class IdentityServerHostMigrationsDbContextFactory : IDesignTimeDbContextFactory + public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args) { - public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); - return new IdentityServerHostMigrationsDbContext(builder.Options); - } + return new IdentityServerHostMigrationsDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs index 259e0c9236..6f8bbf0d69 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs @@ -18,60 +18,60 @@ using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource; using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; using Client = Volo.Abp.IdentityServer.Clients.Client; -namespace MyCompanyName.MyProjectName.IdentityServer +namespace MyCompanyName.MyProjectName.IdentityServer; + +public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency { - public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency + private readonly IApiResourceRepository _apiResourceRepository; + private readonly IApiScopeRepository _apiScopeRepository; + private readonly IClientRepository _clientRepository; + private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; + private readonly IGuidGenerator _guidGenerator; + private readonly IPermissionDataSeeder _permissionDataSeeder; + private readonly IConfiguration _configuration; + private readonly ICurrentTenant _currentTenant; + + public IdentityServerDataSeedContributor( + IClientRepository clientRepository, + IApiResourceRepository apiResourceRepository, + IApiScopeRepository apiScopeRepository, + IIdentityResourceDataSeeder identityResourceDataSeeder, + IGuidGenerator guidGenerator, + IPermissionDataSeeder permissionDataSeeder, + IConfiguration configuration, + ICurrentTenant currentTenant) { - private readonly IApiResourceRepository _apiResourceRepository; - private readonly IApiScopeRepository _apiScopeRepository; - private readonly IClientRepository _clientRepository; - private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; - private readonly IGuidGenerator _guidGenerator; - private readonly IPermissionDataSeeder _permissionDataSeeder; - private readonly IConfiguration _configuration; - private readonly ICurrentTenant _currentTenant; - - public IdentityServerDataSeedContributor( - IClientRepository clientRepository, - IApiResourceRepository apiResourceRepository, - IApiScopeRepository apiScopeRepository, - IIdentityResourceDataSeeder identityResourceDataSeeder, - IGuidGenerator guidGenerator, - IPermissionDataSeeder permissionDataSeeder, - IConfiguration configuration, - ICurrentTenant currentTenant) - { - _clientRepository = clientRepository; - _apiResourceRepository = apiResourceRepository; - _apiScopeRepository = apiScopeRepository; - _identityResourceDataSeeder = identityResourceDataSeeder; - _guidGenerator = guidGenerator; - _permissionDataSeeder = permissionDataSeeder; - _configuration = configuration; - _currentTenant = currentTenant; - } + _clientRepository = clientRepository; + _apiResourceRepository = apiResourceRepository; + _apiScopeRepository = apiScopeRepository; + _identityResourceDataSeeder = identityResourceDataSeeder; + _guidGenerator = guidGenerator; + _permissionDataSeeder = permissionDataSeeder; + _configuration = configuration; + _currentTenant = currentTenant; + } - [UnitOfWork] - public virtual async Task SeedAsync(DataSeedContext context) + [UnitOfWork] + public virtual async Task SeedAsync(DataSeedContext context) + { + using (_currentTenant.Change(context?.TenantId)) { - using (_currentTenant.Change(context?.TenantId)) - { - await _identityResourceDataSeeder.CreateStandardResourcesAsync(); - await CreateApiResourcesAsync(); - await CreateApiScopesAsync(); - await CreateClientsAsync(); - } + await _identityResourceDataSeeder.CreateStandardResourcesAsync(); + await CreateApiResourcesAsync(); + await CreateApiScopesAsync(); + await CreateClientsAsync(); } + } - private async Task CreateApiScopesAsync() - { - await CreateApiScopeAsync("MyProjectName"); - } + private async Task CreateApiScopesAsync() + { + await CreateApiScopeAsync("MyProjectName"); + } - private async Task CreateApiResourcesAsync() + private async Task CreateApiResourcesAsync() + { + var commonApiUserClaims = new[] { - var commonApiUserClaims = new[] - { "email", "email_verified", "name", @@ -80,57 +80,57 @@ namespace MyCompanyName.MyProjectName.IdentityServer "role" }; - await CreateApiResourceAsync("MyProjectName", commonApiUserClaims); - } + await CreateApiResourceAsync("MyProjectName", commonApiUserClaims); + } - private async Task CreateApiResourceAsync(string name, IEnumerable claims) + private async Task CreateApiResourceAsync(string name, IEnumerable claims) + { + var apiResource = await _apiResourceRepository.FindByNameAsync(name); + if (apiResource == null) { - var apiResource = await _apiResourceRepository.FindByNameAsync(name); - if (apiResource == null) - { - apiResource = await _apiResourceRepository.InsertAsync( - new ApiResource( - _guidGenerator.Create(), - name, - name + " API" - ), - autoSave: true - ); - } - - foreach (var claim in claims) - { - if (apiResource.FindClaim(claim) == null) - { - apiResource.AddUserClaim(claim); - } - } - - return await _apiResourceRepository.UpdateAsync(apiResource); + apiResource = await _apiResourceRepository.InsertAsync( + new ApiResource( + _guidGenerator.Create(), + name, + name + " API" + ), + autoSave: true + ); } - private async Task CreateApiScopeAsync(string name) + foreach (var claim in claims) { - var apiScope = await _apiScopeRepository.FindByNameAsync(name); - if (apiScope == null) + if (apiResource.FindClaim(claim) == null) { - apiScope = await _apiScopeRepository.InsertAsync( - new ApiScope( - _guidGenerator.Create(), - name, - name + " API" - ), - autoSave: true - ); + apiResource.AddUserClaim(claim); } + } + + return await _apiResourceRepository.UpdateAsync(apiResource); + } - return apiScope; + private async Task CreateApiScopeAsync(string name) + { + var apiScope = await _apiScopeRepository.FindByNameAsync(name); + if (apiScope == null) + { + apiScope = await _apiScopeRepository.InsertAsync( + new ApiScope( + _guidGenerator.Create(), + name, + name + " API" + ), + autoSave: true + ); } - private async Task CreateClientsAsync() + return apiScope; + } + + private async Task CreateClientsAsync() + { + var commonScopes = new[] { - var commonScopes = new[] - { "email", "openid", "profile", @@ -140,185 +140,184 @@ namespace MyCompanyName.MyProjectName.IdentityServer "MyProjectName" }; - var configurationSection = _configuration.GetSection("IdentityServer:Clients"); + var configurationSection = _configuration.GetSection("IdentityServer:Clients"); - //Web Client - var webClientId = configurationSection["MyProjectName_Web:ClientId"]; - if (!webClientId.IsNullOrWhiteSpace()) - { - var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/'); - - /* MyProjectName_Web client is only needed if you created a tiered - * solution. Otherwise, you can delete this client. */ - - await CreateClientAsync( - name: webClientId, - scopes: commonScopes, - grantTypes: new[] { "hybrid" }, - secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(), - redirectUri: $"{webClientRootUrl}signin-oidc", - postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc", - frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout", - corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } - ); - } + //Web Client + var webClientId = configurationSection["MyProjectName_Web:ClientId"]; + if (!webClientId.IsNullOrWhiteSpace()) + { + var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/'); - //Console Test / Angular Client - var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; - if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) - { - var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); - - await CreateClientAsync( - name: consoleAndAngularClientId, - scopes: commonScopes, - grantTypes: new[] { "password", "client_credentials", "authorization_code" }, - secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), - requireClientSecret: false, - redirectUri: webClientRootUrl, - postLogoutRedirectUri: webClientRootUrl, - corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } - ); - } + /* MyProjectName_Web client is only needed if you created a tiered + * solution. Otherwise, you can delete this client. */ - // Blazor Client - var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"]; - if (!blazorClientId.IsNullOrWhiteSpace()) - { - var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/'); - - await CreateClientAsync( - name: blazorClientId, - scopes: commonScopes, - grantTypes: new[] { "authorization_code" }, - secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(), - requireClientSecret: false, - redirectUri: $"{blazorRootUrl}/authentication/login-callback", - postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback", - corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") } - ); - } + await CreateClientAsync( + name: webClientId, + scopes: commonScopes, + grantTypes: new[] { "hybrid" }, + secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(), + redirectUri: $"{webClientRootUrl}signin-oidc", + postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc", + frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout", + corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } + ); + } - // Swagger Client - var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; - if (!swaggerClientId.IsNullOrWhiteSpace()) - { - var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); - - await CreateClientAsync( - name: swaggerClientId, - scopes: commonScopes, - grantTypes: new[] { "authorization_code" }, - secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(), - requireClientSecret: false, - redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", - corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") } - ); - } + //Console Test / Angular Client + var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; + if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) + { + var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); + + await CreateClientAsync( + name: consoleAndAngularClientId, + scopes: commonScopes, + grantTypes: new[] { "password", "client_credentials", "authorization_code" }, + secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), + requireClientSecret: false, + redirectUri: webClientRootUrl, + postLogoutRedirectUri: webClientRootUrl, + corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } + ); } - private async Task CreateClientAsync( - string name, - IEnumerable scopes, - IEnumerable grantTypes, - string secret = null, - string redirectUri = null, - string postLogoutRedirectUri = null, - string frontChannelLogoutUri = null, - bool requireClientSecret = true, - bool requirePkce = false, - IEnumerable permissions = null, - IEnumerable corsOrigins = null) + // Blazor Client + var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"]; + if (!blazorClientId.IsNullOrWhiteSpace()) { - var client = await _clientRepository.FindByClientIdAsync(name); - if (client == null) - { - client = await _clientRepository.InsertAsync( - new Client( - _guidGenerator.Create(), - name - ) - { - ClientName = name, - ProtocolType = "oidc", - Description = name, - AlwaysIncludeUserClaimsInIdToken = true, - AllowOfflineAccess = true, - AbsoluteRefreshTokenLifetime = 31536000, //365 days + var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/'); + + await CreateClientAsync( + name: blazorClientId, + scopes: commonScopes, + grantTypes: new[] { "authorization_code" }, + secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(), + requireClientSecret: false, + redirectUri: $"{blazorRootUrl}/authentication/login-callback", + postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback", + corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") } + ); + } + + // Swagger Client + var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; + if (!swaggerClientId.IsNullOrWhiteSpace()) + { + var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); + + await CreateClientAsync( + name: swaggerClientId, + scopes: commonScopes, + grantTypes: new[] { "authorization_code" }, + secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(), + requireClientSecret: false, + redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", + corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") } + ); + } + } + + private async Task CreateClientAsync( + string name, + IEnumerable scopes, + IEnumerable grantTypes, + string secret = null, + string redirectUri = null, + string postLogoutRedirectUri = null, + string frontChannelLogoutUri = null, + bool requireClientSecret = true, + bool requirePkce = false, + IEnumerable permissions = null, + IEnumerable corsOrigins = null) + { + var client = await _clientRepository.FindByClientIdAsync(name); + if (client == null) + { + client = await _clientRepository.InsertAsync( + new Client( + _guidGenerator.Create(), + name + ) + { + ClientName = name, + ProtocolType = "oidc", + Description = name, + AlwaysIncludeUserClaimsInIdToken = true, + AllowOfflineAccess = true, + AbsoluteRefreshTokenLifetime = 31536000, //365 days AccessTokenLifetime = 31536000, //365 days AuthorizationCodeLifetime = 300, - IdentityTokenLifetime = 300, - RequireConsent = false, - FrontChannelLogoutUri = frontChannelLogoutUri, - RequireClientSecret = requireClientSecret, - RequirePkce = requirePkce - }, - autoSave: true - ); - } + IdentityTokenLifetime = 300, + RequireConsent = false, + FrontChannelLogoutUri = frontChannelLogoutUri, + RequireClientSecret = requireClientSecret, + RequirePkce = requirePkce + }, + autoSave: true + ); + } - foreach (var scope in scopes) + foreach (var scope in scopes) + { + if (client.FindScope(scope) == null) { - if (client.FindScope(scope) == null) - { - client.AddScope(scope); - } + client.AddScope(scope); } + } - foreach (var grantType in grantTypes) + foreach (var grantType in grantTypes) + { + if (client.FindGrantType(grantType) == null) { - if (client.FindGrantType(grantType) == null) - { - client.AddGrantType(grantType); - } + client.AddGrantType(grantType); } + } - if (!secret.IsNullOrEmpty()) + if (!secret.IsNullOrEmpty()) + { + if (client.FindSecret(secret) == null) { - if (client.FindSecret(secret) == null) - { - client.AddSecret(secret); - } + client.AddSecret(secret); } + } - if (redirectUri != null) + if (redirectUri != null) + { + if (client.FindRedirectUri(redirectUri) == null) { - if (client.FindRedirectUri(redirectUri) == null) - { - client.AddRedirectUri(redirectUri); - } + client.AddRedirectUri(redirectUri); } + } - if (postLogoutRedirectUri != null) + if (postLogoutRedirectUri != null) + { + if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) { - if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) - { - client.AddPostLogoutRedirectUri(postLogoutRedirectUri); - } + client.AddPostLogoutRedirectUri(postLogoutRedirectUri); } + } - if (permissions != null) - { - await _permissionDataSeeder.SeedAsync( - ClientPermissionValueProvider.ProviderName, - name, - permissions, - null - ); - } + if (permissions != null) + { + await _permissionDataSeeder.SeedAsync( + ClientPermissionValueProvider.ProviderName, + name, + permissions, + null + ); + } - if (corsOrigins != null) + if (corsOrigins != null) + { + foreach (var origin in corsOrigins) { - foreach (var origin in corsOrigins) + if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null) { - if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null) - { - client.AddCorsOrigin(origin); - } + client.AddCorsOrigin(origin); } } - - return await _clientRepository.UpdateAsync(client); } + + return await _clientRepository.UpdateAsync(client); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20211105130012_Initial.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20211105130012_Initial.cs index abec77f8c4..0dee1bdcf8 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20211105130012_Initial.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20211105130012_Initial.cs @@ -3,1339 +3,1293 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace MyCompanyName.MyProjectName.Migrations +namespace MyCompanyName.MyProjectName.Migrations; + +public partial class Initial : Migration { - public partial class Initial : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpAuditLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - TenantName = table.Column(type: "nvarchar(max)", nullable: true), - ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), - ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Exceptions = table.Column(type: "nvarchar(max)", nullable: true), - Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - HttpStatusCode = table.Column(type: "int", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpClaimTypes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Required = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ValueType = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpFeatureValues", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpLinkUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), - SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), - TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), - TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnits", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), - DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); - table.ForeignKey( - name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", - column: x => x.ParentId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "AbpPermissionGrants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoles", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsDefault = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - IsPublic = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSecurityLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSettings", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSettings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpTenants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), - PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - IsActive = table.Column(type: "bit", nullable: false), - TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), - LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResources", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Enabled = table.Column(type: "bit", nullable: false), - AllowedAccessTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Enabled = table.Column(type: "bit", nullable: false), - Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Required = table.Column(type: "bit", nullable: false), - Emphasize = table.Column(type: "bit", nullable: false), - ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClients", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - ClientName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - ClientUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - LogoUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - Enabled = table.Column(type: "bit", nullable: false), - ProtocolType = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - RequireClientSecret = table.Column(type: "bit", nullable: false), - RequireConsent = table.Column(type: "bit", nullable: false), - AllowRememberConsent = table.Column(type: "bit", nullable: false), - AlwaysIncludeUserClaimsInIdToken = table.Column(type: "bit", nullable: false), - RequirePkce = table.Column(type: "bit", nullable: false), - AllowPlainTextPkce = table.Column(type: "bit", nullable: false), - RequireRequestObject = table.Column(type: "bit", nullable: false), - AllowAccessTokensViaBrowser = table.Column(type: "bit", nullable: false), - FrontChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - FrontChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), - BackChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - BackChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), - AllowOfflineAccess = table.Column(type: "bit", nullable: false), - IdentityTokenLifetime = table.Column(type: "int", nullable: false), - AllowedIdentityTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - AccessTokenLifetime = table.Column(type: "int", nullable: false), - AuthorizationCodeLifetime = table.Column(type: "int", nullable: false), - ConsentLifetime = table.Column(type: "int", nullable: true), - AbsoluteRefreshTokenLifetime = table.Column(type: "int", nullable: false), - SlidingRefreshTokenLifetime = table.Column(type: "int", nullable: false), - RefreshTokenUsage = table.Column(type: "int", nullable: false), - UpdateAccessTokenClaimsOnRefresh = table.Column(type: "bit", nullable: false), - RefreshTokenExpiration = table.Column(type: "int", nullable: false), - AccessTokenType = table.Column(type: "int", nullable: false), - EnableLocalLogin = table.Column(type: "bit", nullable: false), - IncludeJwtId = table.Column(type: "bit", nullable: false), - AlwaysSendClientClaims = table.Column(type: "bit", nullable: false), - ClientClaimsPrefix = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - PairWiseSubjectSalt = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - UserSsoLifetime = table.Column(type: "int", nullable: true), - UserCodeType = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - DeviceCodeLifetime = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerDeviceFlowCodes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - DeviceCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - UserCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Expiration = table.Column(type: "datetime2", nullable: false), - Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityResources", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Enabled = table.Column(type: "bit", nullable: false), - Required = table.Column(type: "bit", nullable: false), - Emphasize = table.Column(type: "bit", nullable: false), - ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerPersistedGrants", - columns: table => new - { - Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - Expiration = table.Column(type: "datetime2", nullable: true), - ConsumedTime = table.Column(type: "datetime2", nullable: true), - Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), - Id = table.Column(type: "uniqueidentifier", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); - }); - - migrationBuilder.CreateTable( - name: "AbpAuditLogActions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); - table.ForeignKey( - name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ChangeTime = table.Column(type: "datetime2", nullable: false), - ChangeType = table.Column(type: "tinyint", nullable: false), - EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnitRoles", - columns: table => new - { - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpRoleClaims", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - 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: "AbpTenantConnectionStrings", - columns: table => new - { - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Value = table.Column(type: "nvarchar(1024)", 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 - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - 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 - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), - ProviderDisplayName = table.Column(type: "nvarchar(128)", 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: "AbpUserOrganizationUnits", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserRoles", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - 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 - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Value = table.Column(type: "nvarchar(max)", 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: "IdentityServerApiResourceClaims", - columns: table => new - { - Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceClaims", x => new { x.ApiResourceId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResourceProperties", - columns: table => new - { - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResourceScopes", - columns: table => new - { - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResourceSecrets", - columns: table => new - { - Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Expiration = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopeClaims", - columns: table => new - { - Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiScopeId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId", - column: x => x.ApiScopeId, - principalTable: "IdentityServerApiScopes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopeProperties", - columns: table => new - { - ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_ApiScopeId", - column: x => x.ApiScopeId, - principalTable: "IdentityServerApiScopes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientClaims", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientCorsOrigins", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Origin = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); - table.ForeignKey( - name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientGrantTypes", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - GrantType = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); - table.ForeignKey( - name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientIdPRestrictions", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Provider = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); - table.ForeignKey( - name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientPostLogoutRedirectUris", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - PostLogoutRedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); - table.ForeignKey( - name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientProperties", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientRedirectUris", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - RedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); - table.ForeignKey( - name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientScopes", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); - table.ForeignKey( - name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientSecrets", - columns: table => new - { - Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Description = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - Expiration = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityResourceClaims", - columns: table => new - { - Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityResources_IdentityResourceId", - column: x => x.IdentityResourceId, - principalTable: "IdentityServerIdentityResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityResourceProperties", - columns: table => new - { - IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdentityResources_IdentityResourceId", - column: x => x.IdentityResourceId, - principalTable: "IdentityServerIdentityResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityPropertyChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), - NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", - column: x => x.EntityChangeId, - principalTable: "AbpEntityChanges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_AuditLogId", - table: "AbpAuditLogActions", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", - table: "AbpAuditLogActions", - columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "UserId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_AuditLogId", - table: "AbpEntityChanges", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", - table: "AbpEntityChanges", - columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityPropertyChanges_EntityChangeId", - table: "AbpEntityPropertyChanges", - column: "EntityChangeId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", - table: "AbpFeatureValues", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", - table: "AbpLinkUsers", - columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, - unique: true, - filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", - table: "AbpOrganizationUnitRoles", - columns: new[] { "RoleId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_Code", - table: "AbpOrganizationUnits", - column: "Code"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_ParentId", - table: "AbpOrganizationUnits", - column: "ParentId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", - table: "AbpPermissionGrants", - columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[TenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoleClaims_RoleId", - table: "AbpRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoles_NormalizedName", - table: "AbpRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Action", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Action" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_ApplicationName", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "ApplicationName" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Identity", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Identity" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_UserId", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSettings_Name_ProviderName_ProviderKey", - table: "AbpSettings", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpTenants_Name", - table: "AbpTenants", - column: "Name"); - - 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_AbpUserOrganizationUnits_UserId_OrganizationUnitId", - table: "AbpUserOrganizationUnits", - columns: new[] { "UserId", "OrganizationUnitId" }); - - 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_IdentityServerClients_ClientId", - table: "IdentityServerClients", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", - table: "IdentityServerDeviceFlowCodes", - column: "DeviceCode", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_Expiration", - table: "IdentityServerDeviceFlowCodes", - column: "Expiration"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_UserCode", - table: "IdentityServerDeviceFlowCodes", - column: "UserCode"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_Expiration", - table: "IdentityServerPersistedGrants", - column: "Expiration"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", - table: "IdentityServerPersistedGrants", - columns: new[] { "SubjectId", "ClientId", "Type" }); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type", - table: "IdentityServerPersistedGrants", - columns: new[] { "SubjectId", "SessionId", "Type" }); - } + migrationBuilder.CreateTable( + name: "AbpAuditLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + TenantName = table.Column(type: "nvarchar(max)", nullable: true), + ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), + ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Exceptions = table.Column(type: "nvarchar(max)", nullable: true), + Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + HttpStatusCode = table.Column(type: "int", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Required = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ValueType = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpFeatureValues", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpLinkUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), + SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), + TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), + TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), + DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsDefault = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + IsPublic = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSecurityLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + IsActive = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResources", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Enabled = table.Column(type: "bit", nullable: false), + AllowedAccessTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Enabled = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Required = table.Column(type: "bit", nullable: false), + Emphasize = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClients", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ClientName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + ClientUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + LogoUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + Enabled = table.Column(type: "bit", nullable: false), + ProtocolType = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + RequireClientSecret = table.Column(type: "bit", nullable: false), + RequireConsent = table.Column(type: "bit", nullable: false), + AllowRememberConsent = table.Column(type: "bit", nullable: false), + AlwaysIncludeUserClaimsInIdToken = table.Column(type: "bit", nullable: false), + RequirePkce = table.Column(type: "bit", nullable: false), + AllowPlainTextPkce = table.Column(type: "bit", nullable: false), + RequireRequestObject = table.Column(type: "bit", nullable: false), + AllowAccessTokensViaBrowser = table.Column(type: "bit", nullable: false), + FrontChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + FrontChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + BackChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + BackChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + AllowOfflineAccess = table.Column(type: "bit", nullable: false), + IdentityTokenLifetime = table.Column(type: "int", nullable: false), + AllowedIdentityTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + AccessTokenLifetime = table.Column(type: "int", nullable: false), + AuthorizationCodeLifetime = table.Column(type: "int", nullable: false), + ConsentLifetime = table.Column(type: "int", nullable: true), + AbsoluteRefreshTokenLifetime = table.Column(type: "int", nullable: false), + SlidingRefreshTokenLifetime = table.Column(type: "int", nullable: false), + RefreshTokenUsage = table.Column(type: "int", nullable: false), + UpdateAccessTokenClaimsOnRefresh = table.Column(type: "bit", nullable: false), + RefreshTokenExpiration = table.Column(type: "int", nullable: false), + AccessTokenType = table.Column(type: "int", nullable: false), + EnableLocalLogin = table.Column(type: "bit", nullable: false), + IncludeJwtId = table.Column(type: "bit", nullable: false), + AlwaysSendClientClaims = table.Column(type: "bit", nullable: false), + ClientClaimsPrefix = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + PairWiseSubjectSalt = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + UserSsoLifetime = table.Column(type: "int", nullable: true), + UserCodeType = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + DeviceCodeLifetime = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerDeviceFlowCodes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + DeviceCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + UserCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: false), + Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResources", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Enabled = table.Column(type: "bit", nullable: false), + Required = table.Column(type: "bit", nullable: false), + Emphasize = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerPersistedGrants", + columns: table => new { + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + Expiration = table.Column(type: "datetime2", nullable: true), + ConsumedTime = table.Column(type: "datetime2", nullable: true), + Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), + Id = table.Column(type: "uniqueidentifier", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); + }); + + migrationBuilder.CreateTable( + name: "AbpAuditLogActions", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); + table.ForeignKey( + name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ChangeTime = table.Column(type: "datetime2", nullable: false), + ChangeType = table.Column(type: "tinyint", nullable: false), + EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new { + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + 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: "AbpTenantConnectionStrings", + columns: table => new { + TenantId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Value = table.Column(type: "nvarchar(1024)", 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 { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + 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 { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(128)", 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: "AbpUserOrganizationUnits", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + 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 { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Value = table.Column(type: "nvarchar(max)", 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: "IdentityServerApiResourceClaims", + columns: table => new { + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceClaims", x => new { x.ApiResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceProperties", + columns: table => new { + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceScopes", + columns: table => new { + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceSecrets", + columns: table => new { + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopeClaims", + columns: table => new { + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiScopeId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId", + column: x => x.ApiScopeId, + principalTable: "IdentityServerApiScopes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopeProperties", + columns: table => new { + ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_ApiScopeId", + column: x => x.ApiScopeId, + principalTable: "IdentityServerApiScopes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientClaims", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientCorsOrigins", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Origin = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); + table.ForeignKey( + name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientGrantTypes", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + GrantType = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); + table.ForeignKey( + name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientIdPRestrictions", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Provider = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); + table.ForeignKey( + name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientPostLogoutRedirectUris", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + PostLogoutRedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientProperties", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientRedirectUris", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + RedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientScopes", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); + table.ForeignKey( + name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientSecrets", + columns: table => new { + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResourceClaims", + columns: table => new { + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityResources_IdentityResourceId", + column: x => x.IdentityResourceId, + principalTable: "IdentityServerIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResourceProperties", + columns: table => new { + IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdentityResources_IdentityResourceId", + column: x => x.IdentityResourceId, + principalTable: "IdentityServerIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityPropertyChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), + NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", + column: x => x.EntityChangeId, + principalTable: "AbpEntityChanges", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_AuditLogId", + table: "AbpAuditLogActions", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", + table: "AbpAuditLogActions", + columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "UserId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_AuditLogId", + table: "AbpEntityChanges", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", + table: "AbpEntityChanges", + columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityPropertyChanges_EntityChangeId", + table: "AbpEntityPropertyChanges", + column: "EntityChangeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", + table: "AbpFeatureValues", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", + table: "AbpLinkUsers", + columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, + unique: true, + filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[TenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Action", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Action" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_ApplicationName", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "ApplicationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Identity", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Identity" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_UserId", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name"); + + 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_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + 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_IdentityServerClients_ClientId", + table: "IdentityServerClients", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", + table: "IdentityServerDeviceFlowCodes", + column: "DeviceCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_Expiration", + table: "IdentityServerDeviceFlowCodes", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_UserCode", + table: "IdentityServerDeviceFlowCodes", + column: "UserCode"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_Expiration", + table: "IdentityServerPersistedGrants", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", + table: "IdentityServerPersistedGrants", + columns: new[] { "SubjectId", "ClientId", "Type" }); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type", + table: "IdentityServerPersistedGrants", + columns: new[] { "SubjectId", "SessionId", "Type" }); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AbpAuditLogActions"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpAuditLogActions"); - migrationBuilder.DropTable( - name: "AbpClaimTypes"); + migrationBuilder.DropTable( + name: "AbpClaimTypes"); - migrationBuilder.DropTable( - name: "AbpEntityPropertyChanges"); + migrationBuilder.DropTable( + name: "AbpEntityPropertyChanges"); - migrationBuilder.DropTable( - name: "AbpFeatureValues"); + migrationBuilder.DropTable( + name: "AbpFeatureValues"); - migrationBuilder.DropTable( - name: "AbpLinkUsers"); + migrationBuilder.DropTable( + name: "AbpLinkUsers"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnitRoles"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); - migrationBuilder.DropTable( - name: "AbpPermissionGrants"); + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); - migrationBuilder.DropTable( - name: "AbpRoleClaims"); + migrationBuilder.DropTable( + name: "AbpRoleClaims"); - migrationBuilder.DropTable( - name: "AbpSecurityLogs"); + migrationBuilder.DropTable( + name: "AbpSecurityLogs"); - migrationBuilder.DropTable( - name: "AbpSettings"); + migrationBuilder.DropTable( + name: "AbpSettings"); - migrationBuilder.DropTable( - name: "AbpTenantConnectionStrings"); + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); - migrationBuilder.DropTable( - name: "AbpUserClaims"); + migrationBuilder.DropTable( + name: "AbpUserClaims"); - migrationBuilder.DropTable( - name: "AbpUserLogins"); + migrationBuilder.DropTable( + name: "AbpUserLogins"); - migrationBuilder.DropTable( - name: "AbpUserOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpUserRoles"); + migrationBuilder.DropTable( + name: "AbpUserRoles"); - migrationBuilder.DropTable( - name: "AbpUserTokens"); + migrationBuilder.DropTable( + name: "AbpUserTokens"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceClaims"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceClaims"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceProperties"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceProperties"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceScopes"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceScopes"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceSecrets"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceSecrets"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopeClaims"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopeClaims"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopeProperties"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopeProperties"); - migrationBuilder.DropTable( - name: "IdentityServerClientClaims"); + migrationBuilder.DropTable( + name: "IdentityServerClientClaims"); - migrationBuilder.DropTable( - name: "IdentityServerClientCorsOrigins"); + migrationBuilder.DropTable( + name: "IdentityServerClientCorsOrigins"); - migrationBuilder.DropTable( - name: "IdentityServerClientGrantTypes"); + migrationBuilder.DropTable( + name: "IdentityServerClientGrantTypes"); - migrationBuilder.DropTable( - name: "IdentityServerClientIdPRestrictions"); + migrationBuilder.DropTable( + name: "IdentityServerClientIdPRestrictions"); - migrationBuilder.DropTable( - name: "IdentityServerClientPostLogoutRedirectUris"); + migrationBuilder.DropTable( + name: "IdentityServerClientPostLogoutRedirectUris"); - migrationBuilder.DropTable( - name: "IdentityServerClientProperties"); + migrationBuilder.DropTable( + name: "IdentityServerClientProperties"); - migrationBuilder.DropTable( - name: "IdentityServerClientRedirectUris"); + migrationBuilder.DropTable( + name: "IdentityServerClientRedirectUris"); - migrationBuilder.DropTable( - name: "IdentityServerClientScopes"); + migrationBuilder.DropTable( + name: "IdentityServerClientScopes"); - migrationBuilder.DropTable( - name: "IdentityServerClientSecrets"); + migrationBuilder.DropTable( + name: "IdentityServerClientSecrets"); - migrationBuilder.DropTable( - name: "IdentityServerDeviceFlowCodes"); + migrationBuilder.DropTable( + name: "IdentityServerDeviceFlowCodes"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityResourceClaims"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityResourceClaims"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityResourceProperties"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityResourceProperties"); - migrationBuilder.DropTable( - name: "IdentityServerPersistedGrants"); + migrationBuilder.DropTable( + name: "IdentityServerPersistedGrants"); - migrationBuilder.DropTable( - name: "AbpEntityChanges"); + migrationBuilder.DropTable( + name: "AbpEntityChanges"); - migrationBuilder.DropTable( - name: "AbpTenants"); + migrationBuilder.DropTable( + name: "AbpTenants"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpRoles"); + migrationBuilder.DropTable( + name: "AbpRoles"); - migrationBuilder.DropTable( - name: "AbpUsers"); + migrationBuilder.DropTable( + name: "AbpUsers"); - migrationBuilder.DropTable( - name: "IdentityServerApiResources"); + migrationBuilder.DropTable( + name: "IdentityServerApiResources"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopes"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopes"); - migrationBuilder.DropTable( - name: "IdentityServerClients"); + migrationBuilder.DropTable( + name: "IdentityServerClients"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityResources"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityResources"); - migrationBuilder.DropTable( - name: "AbpAuditLogs"); - } + migrationBuilder.DropTable( + name: "AbpAuditLogs"); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index 8aa6dea816..b6fc071e14 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -49,198 +49,197 @@ using Volo.Abp.TenantManagement.EntityFrameworkCore; using Volo.Abp.Threading; using Volo.Abp.UI.Navigation.Urls; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpAccountApplicationModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpIdentityServerEntityFrameworkCoreModule), + typeof(AbpPermissionManagementDomainIdentityModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpSettingManagementApplicationModule), + typeof(AbpSettingManagementHttpApiModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementApplicationModule), + typeof(AbpFeatureManagementHttpApiModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpTenantManagementHttpApiModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) + )] +public class MyProjectNameIdentityServerModule : AbpModule { - [DependsOn( - typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAccountApplicationModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpAspNetCoreMvcUiMultiTenancyModule), - typeof(AbpAspNetCoreMvcModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpIdentityApplicationModule), - typeof(AbpIdentityHttpApiModule), - typeof(AbpIdentityServerEntityFrameworkCoreModule), - typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpPermissionManagementHttpApiModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpSettingManagementApplicationModule), - typeof(AbpSettingManagementHttpApiModule), - typeof(AbpFeatureManagementEntityFrameworkCoreModule), - typeof(AbpFeatureManagementApplicationModule), - typeof(AbpFeatureManagementHttpApiModule), - typeof(AbpTenantManagementEntityFrameworkCoreModule), - typeof(AbpTenantManagementApplicationModule), - typeof(AbpTenantManagementHttpApiModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameIdentityServerModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); - - Configure(options => - { - options.UseSqlServer(); - }); + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - context.Services.AddAbpSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); + Configure(options => + { + options.UseSqlServer(); + }); - Configure(options => + context.Services.AddAbpSwaggerGen( + options => { - options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); - options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); - options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); - options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); - options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); - options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); - options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); - options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); - options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); - options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); - options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); - options.Languages.Add(new LanguageInfo("es", "es", "Español")); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - Configure(options => - { + Configure(options => + { + options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); + options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); + options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); + options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); + options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); + options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); + options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); + options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); + options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); + options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); + options.Languages.Add(new LanguageInfo("es", "es", "Español")); + }); + + Configure(options => + { //options.IsEnabledForGetRequests = true; options.ApplicationName = "AuthServer"; - }); - - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); + }); - context.Services.AddAuthentication() - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.Audience = configuration["AuthServer:ApiName"]; - }); + Configure(options => + { + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); - Configure(options => + context.Services.AddAuthentication() + .AddJwtBearer(options => { - options.KeyPrefix = "MyProjectName:"; + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = configuration["AuthServer:ApiName"]; }); - Configure(options => - { - options.IsEnabled = MultiTenancyConsts.IsEnabled; - }); + Configure(options => + { + options.KeyPrefix = "MyProjectName:"; + }); - var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); - } + Configure(options => + { + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); + + var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); + if (!hostingEnvironment.IsDevelopment()) + { + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); + } - context.Services.AddCors(options => + context.Services.AddCors(options => + { + options.AddDefaultPolicy(builder => { - options.AddDefaultPolicy(builder => - { - builder - .WithOrigins( - configuration["App:CorsOrigins"] - .Split(",", StringSplitOptions.RemoveEmptyEntries) - .Select(o => o.RemovePostFix("/")) - .ToArray() - ) - .WithAbpExposedHeaders() - .SetIsOriginAllowedToAllowWildcardSubdomains() - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials(); - }); + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); }); + }); #if DEBUG - context.Services.Replace(ServiceDescriptor.Singleton()); + context.Services.Replace(ServiceDescriptor.Singleton()); #endif - } + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseErrorPage(); - app.UseHsts(); - } + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseErrorPage(); + app.UseHsts(); + } - app.UseHttpsRedirection(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseCors(); - app.UseAuthentication(); - app.UseJwtTokenMiddleware(); + app.UseHttpsRedirection(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseCors(); + app.UseAuthentication(); + app.UseJwtTokenMiddleware(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - app.UseAbpRequestLocalization(); - app.UseIdentityServer(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); - }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + app.UseAbpRequestLocalization(); + app.UseIdentityServer(); + app.UseAuthorization(); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); + }); + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); - SeedData(context); - } + SeedData(context); + } - private void SeedData(ApplicationInitializationContext context) + private void SeedData(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => + using (var scope = context.ServiceProvider.CreateScope()) { - using (var scope = context.ServiceProvider.CreateScope()) - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - } - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + } + }); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs index cfd795c936..e8230ee00c 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs @@ -1,11 +1,10 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; -namespace MyCompanyName.MyProjectName.Pages +namespace MyCompanyName.MyProjectName.Pages; + +public class IndexModel : AbpPageModel { - public class IndexModel : AbpPageModel + public void OnGet() { - public void OnGet() - { - } } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs index b2811a98ba..500a2cfc00 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs @@ -6,51 +6,50 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.Async(c => c.File("Logs/logs.txt")) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("Logs/logs.txt")) #if DEBUG .WriteTo.Async(c => c.Console()) #endif .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Startup.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Startup.cs index df50584cb5..70990fa4da 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Startup.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Startup.cs @@ -4,18 +4,17 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs index 318e7191a2..bc51284db7 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs @@ -1,9 +1,8 @@ using Volo.Abp.AspNetCore.Mvc.Authentication; -namespace MyCompanyName.MyProjectName.Controllers +namespace MyCompanyName.MyProjectName.Controllers; + +public class AccountController : ChallengeAccountController { - public class AccountController : ChallengeAccountController - { - } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs index 3f6994c9e4..340ce5fb7b 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[Dependency(ReplaceServices = true)] +public class MyProjectNameBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class MyProjectNameBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs index b8069ae329..c6255b4bd1 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs @@ -1,12 +1,11 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class MyProjectNameWebAutoMapperProfile : Profile { - public class MyProjectNameWebAutoMapperProfile : Profile + public MyProjectNameWebAutoMapperProfile() { - public MyProjectNameWebAutoMapperProfile() - { - //Define your AutoMapper configuration here for the Web project. - } + //Define your AutoMapper configuration here for the Web project. } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs index 25f4e103f9..7c47c56d2d 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs @@ -9,48 +9,47 @@ using Volo.Abp.Authorization.Permissions; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class MyProjectNameWebHostMenuContributor : IMenuContributor { - public class MyProjectNameWebHostMenuContributor : IMenuContributor + private readonly IConfiguration _configuration; + + public MyProjectNameWebHostMenuContributor(IConfiguration configuration) { - private readonly IConfiguration _configuration; + _configuration = configuration; + } - public MyProjectNameWebHostMenuContributor(IConfiguration configuration) + public Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name == StandardMenus.User) { - _configuration = configuration; + AddLogoutItemToMenu(context); } - public Task ConfigureMenuAsync(MenuConfigurationContext context) - { - if (context.Menu.Name == StandardMenus.User) - { - AddLogoutItemToMenu(context); - } + return Task.CompletedTask; + } - return Task.CompletedTask; - } + private void AddLogoutItemToMenu(MenuConfigurationContext context) + { + var l = context.GetLocalizer(); - private void AddLogoutItemToMenu(MenuConfigurationContext context) - { - var l = context.GetLocalizer(); - - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Manage", - l["MyAccount"], - $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", - icon: "fa fa-cog", - order: int.MaxValue - 1001, - null, - "_blank" - ).RequireAuthenticated()); - - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Logout", - l["Logout"], - "~/Account/Logout", - "fas fa-power-off", - order: int.MaxValue - 1000 - ).RequireAuthenticated()); - } + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Manage", + l["MyAccount"], + $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", + icon: "fa fa-cog", + order: int.MaxValue - 1001, + null, + "_blank" + ).RequireAuthenticated()); + + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Logout", + l["Logout"], + "~/Account/Logout", + "fas fa-power-off", + order: int.MaxValue - 1000 + ).RequireAuthenticated()); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs index df87db8359..1c4ec67ecd 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs @@ -50,213 +50,212 @@ using Volo.Abp.UI; using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameWebModule), + typeof(MyProjectNameHttpApiClientModule), + typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule), + typeof(AbpAspNetCoreMvcClientModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpHttpClientWebModule), + typeof(AbpHttpClientIdentityModelWebModule), + typeof(AbpIdentityWebModule), + typeof(AbpIdentityHttpApiClientModule), + typeof(AbpFeatureManagementWebModule), + typeof(AbpFeatureManagementHttpApiClientModule), + typeof(AbpTenantManagementWebModule), + typeof(AbpTenantManagementHttpApiClientModule), + typeof(AbpPermissionManagementHttpApiClientModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) + )] +public class MyProjectNameWebHostModule : AbpModule { - [DependsOn( - typeof(MyProjectNameWebModule), - typeof(MyProjectNameHttpApiClientModule), - typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule), - typeof(AbpAspNetCoreMvcClientModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpHttpClientWebModule), - typeof(AbpHttpClientIdentityModelWebModule), - typeof(AbpIdentityWebModule), - typeof(AbpIdentityHttpApiClientModule), - typeof(AbpFeatureManagementWebModule), - typeof(AbpFeatureManagementHttpApiClientModule), - typeof(AbpTenantManagementWebModule), - typeof(AbpTenantManagementHttpApiClientModule), - typeof(AbpPermissionManagementHttpApiClientModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameWebHostModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(MyProjectNameResource), - typeof(MyProjectNameDomainSharedModule).Assembly, - typeof(MyProjectNameApplicationContractsModule).Assembly, - typeof(MyProjectNameWebHostModule).Assembly - ); - }); - } + options.AddAssemblyResource( + typeof(MyProjectNameResource), + typeof(MyProjectNameDomainSharedModule).Assembly, + typeof(MyProjectNameApplicationContractsModule).Assembly, + typeof(MyProjectNameWebHostModule).Assembly + ); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) - { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - ConfigureMenu(configuration); - ConfigureCache(configuration); - ConfigureUrls(configuration); - ConfigureAuthentication(context, configuration); - ConfigureAutoMapper(); - ConfigureVirtualFileSystem(hostingEnvironment); - ConfigureSwaggerServices(context.Services); - ConfigureMultiTenancy(); - ConfigureDataProtection(context, configuration, hostingEnvironment); - } + ConfigureMenu(configuration); + ConfigureCache(configuration); + ConfigureUrls(configuration); + ConfigureAuthentication(context, configuration); + ConfigureAutoMapper(); + ConfigureVirtualFileSystem(hostingEnvironment); + ConfigureSwaggerServices(context.Services); + ConfigureMultiTenancy(); + ConfigureDataProtection(context, configuration, hostingEnvironment); + } - private void ConfigureMenu(IConfiguration configuration) + private void ConfigureMenu(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameWebHostMenuContributor(configuration)); - }); - } + options.MenuContributors.Add(new MyProjectNameWebHostMenuContributor(configuration)); + }); + } - private void ConfigureCache(IConfiguration configuration) + private void ConfigureCache(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.KeyPrefix = "MyProjectName:"; - }); - } + options.KeyPrefix = "MyProjectName:"; + }); + } - private void ConfigureUrls(IConfiguration configuration) + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); - } + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); + } - private void ConfigureMultiTenancy() + private void ConfigureMultiTenancy() + { + Configure(options => { - Configure(options => - { - options.IsEnabled = MultiTenancyConsts.IsEnabled; - }); - } + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); + } - private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) - { - context.Services.AddAuthentication(options => - { - options.DefaultScheme = "Cookies"; - options.DefaultChallengeScheme = "oidc"; - }) - .AddCookie("Cookies", options => - { - options.ExpireTimeSpan = TimeSpan.FromDays(365); - }) - .AddAbpOpenIdConnect("oidc", options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.ResponseType = OpenIdConnectResponseType.CodeIdToken; + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAuthentication(options => + { + options.DefaultScheme = "Cookies"; + options.DefaultChallengeScheme = "oidc"; + }) + .AddCookie("Cookies", options => + { + options.ExpireTimeSpan = TimeSpan.FromDays(365); + }) + .AddAbpOpenIdConnect("oidc", options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.ResponseType = OpenIdConnectResponseType.CodeIdToken; - options.ClientId = configuration["AuthServer:ClientId"]; - options.ClientSecret = configuration["AuthServer:ClientSecret"]; + options.ClientId = configuration["AuthServer:ClientId"]; + options.ClientSecret = configuration["AuthServer:ClientSecret"]; - options.SaveTokens = true; - options.GetClaimsFromUserInfoEndpoint = true; + options.SaveTokens = true; + options.GetClaimsFromUserInfoEndpoint = true; - options.Scope.Add("role"); - options.Scope.Add("email"); - options.Scope.Add("phone"); - options.Scope.Add("MyProjectName"); - }); - } + options.Scope.Add("role"); + options.Scope.Add("email"); + options.Scope.Add("phone"); + options.Scope.Add("MyProjectName"); + }); + } - private void ConfigureAutoMapper() + private void ConfigureAutoMapper() + { + Configure(options => { - Configure(options => - { - options.AddMaps(); - }); - } + options.AddMaps(); + }); + } - private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + { + if (hostingEnvironment.IsDevelopment()) { - if (hostingEnvironment.IsDevelopment()) + Configure(options => { - Configure(options => - { // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar))); // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", Path.DirectorySeparatorChar))); - }); - } + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", Path.DirectorySeparatorChar))); + }); } + } - private void ConfigureSwaggerServices(IServiceCollection services) + private void ConfigureSwaggerServices(IServiceCollection services) + { + services.AddAbpSwaggerGen( + options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + } + ); + } + + private void ConfigureDataProtection( + ServiceConfigurationContext context, + IConfiguration configuration, + IWebHostEnvironment hostingEnvironment) + { + var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); + if (!hostingEnvironment.IsDevelopment()) { - services.AddAbpSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - } - ); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } + } - private void ConfigureDataProtection( - ServiceConfigurationContext context, - IConfiguration configuration, - IWebHostEnvironment hostingEnvironment) + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); + + if (env.IsDevelopment()) { - var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); - } + app.UseDeveloperExceptionPage(); } - - public override void OnApplicationInitialization(ApplicationInitializationContext context) + else { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseErrorPage(); - app.UseHsts(); - } + app.UseErrorPage(); + app.UseHsts(); + } - app.UseHttpsRedirection(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); + app.UseHttpsRedirection(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - app.UseAbpRequestLocalization(); - app.UseAuthorization(); + app.UseAbpRequestLocalization(); + app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); - }); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); + }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); - } + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs index 151775007f..4acf096005 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs @@ -1,18 +1,17 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; -namespace MyCompanyName.MyProjectName.Pages +namespace MyCompanyName.MyProjectName.Pages; + +public class IndexModel : MyProjectNamePageModel { - public class IndexModel : MyProjectNamePageModel + public void OnGet() { - public void OnGet() - { - - } - public async Task OnPostLoginAsync() - { - await HttpContext.ChallengeAsync("oidc"); - } } -} \ No newline at end of file + + public async Task OnPostLoginAsync() + { + await HttpContext.ChallengeAsync("oidc"); + } +} diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs index aaea90b89a..05ec7b4ca8 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs @@ -1,13 +1,12 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; -namespace MyCompanyName.MyProjectName.Pages +namespace MyCompanyName.MyProjectName.Pages; + +public abstract class MyProjectNamePageModel : AbpPageModel { - public abstract class MyProjectNamePageModel : AbpPageModel + protected MyProjectNamePageModel() { - protected MyProjectNamePageModel() - { - LocalizationResourceType = typeof(MyProjectNameResource); - } + LocalizationResourceType = typeof(MyProjectNameResource); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Program.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Program.cs index b2811a98ba..500a2cfc00 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Program.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Program.cs @@ -6,51 +6,50 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.Async(c => c.File("Logs/logs.txt")) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("Logs/logs.txt")) #if DEBUG .WriteTo.Async(c => c.Console()) #endif .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Startup.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Startup.cs index 1c5ffbe462..265fb2e7d7 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Startup.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Startup.cs @@ -2,18 +2,17 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs index 7469ef8c64..87a728c91d 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs @@ -7,27 +7,26 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class UnifiedDbContext : AbpDbContext { - public class UnifiedDbContext : AbpDbContext + public UnifiedDbContext(DbContextOptions options) + : base(options) { - public UnifiedDbContext(DbContextOptions options) - : base(options) - { - } + } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); - modelBuilder.ConfigurePermissionManagement(); - modelBuilder.ConfigureSettingManagement(); - modelBuilder.ConfigureAuditLogging(); - modelBuilder.ConfigureIdentity(); - modelBuilder.ConfigureFeatureManagement(); - modelBuilder.ConfigureTenantManagement(); - modelBuilder.ConfigureMyProjectName(); - } + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigureAuditLogging(); + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureFeatureManagement(); + modelBuilder.ConfigureTenantManagement(); + modelBuilder.ConfigureMyProjectName(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs index 4f135e615b..7afb90f239 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs @@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class UnifiedDbContextFactory : IDesignTimeDbContextFactory { - public class UnifiedDbContextFactory : IDesignTimeDbContextFactory + public UnifiedDbContext CreateDbContext(string[] args) { - public UnifiedDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); - return new UnifiedDbContext(builder.Options); - } + return new UnifiedDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20211105130018_Initial.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20211105130018_Initial.cs index 4fc6e66561..ba5eeb4fec 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20211105130018_Initial.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20211105130018_Initial.cs @@ -3,732 +3,709 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace MyCompanyName.MyProjectName.Migrations +namespace MyCompanyName.MyProjectName.Migrations; + +public partial class Initial : Migration { - public partial class Initial : Migration + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AbpAuditLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + TenantName = table.Column(type: "nvarchar(max)", nullable: true), + ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), + ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Exceptions = table.Column(type: "nvarchar(max)", nullable: true), + Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + HttpStatusCode = table.Column(type: "int", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Required = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ValueType = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpFeatureValues", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpLinkUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), + SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), + TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), + TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), + DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsDefault = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + IsPublic = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSecurityLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + IsActive = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpAuditLogActions", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); + table.ForeignKey( + name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ChangeTime = table.Column(type: "datetime2", nullable: false), + ChangeType = table.Column(type: "tinyint", nullable: false), + EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new { + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + 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: "AbpTenantConnectionStrings", + columns: table => new { + TenantId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Value = table.Column(type: "nvarchar(1024)", 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 { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + 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 { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(128)", 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: "AbpUserOrganizationUnits", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + 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 { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Value = table.Column(type: "nvarchar(max)", 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: "AbpEntityPropertyChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), + NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", + column: x => x.EntityChangeId, + principalTable: "AbpEntityChanges", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_AuditLogId", + table: "AbpAuditLogActions", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", + table: "AbpAuditLogActions", + columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "UserId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_AuditLogId", + table: "AbpEntityChanges", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", + table: "AbpEntityChanges", + columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityPropertyChanges_EntityChangeId", + table: "AbpEntityPropertyChanges", + column: "EntityChangeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", + table: "AbpFeatureValues", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", + table: "AbpLinkUsers", + columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, + unique: true, + filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[TenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Action", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Action" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_ApplicationName", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "ApplicationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Identity", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Identity" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_UserId", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name"); + + 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_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + 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) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpAuditLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - TenantName = table.Column(type: "nvarchar(max)", nullable: true), - ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), - ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Exceptions = table.Column(type: "nvarchar(max)", nullable: true), - Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - HttpStatusCode = table.Column(type: "int", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpClaimTypes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Required = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ValueType = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpFeatureValues", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpLinkUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), - SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), - TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), - TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnits", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), - DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); - table.ForeignKey( - name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", - column: x => x.ParentId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "AbpPermissionGrants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoles", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsDefault = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - IsPublic = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSecurityLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSettings", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSettings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpTenants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), - PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - IsActive = table.Column(type: "bit", nullable: false), - TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), - LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpAuditLogActions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); - table.ForeignKey( - name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ChangeTime = table.Column(type: "datetime2", nullable: false), - ChangeType = table.Column(type: "tinyint", nullable: false), - EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnitRoles", - columns: table => new - { - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpRoleClaims", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - 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: "AbpTenantConnectionStrings", - columns: table => new - { - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Value = table.Column(type: "nvarchar(1024)", 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 - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - 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 - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), - ProviderDisplayName = table.Column(type: "nvarchar(128)", 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: "AbpUserOrganizationUnits", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserRoles", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - 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 - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Value = table.Column(type: "nvarchar(max)", 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: "AbpEntityPropertyChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), - NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", - column: x => x.EntityChangeId, - principalTable: "AbpEntityChanges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_AuditLogId", - table: "AbpAuditLogActions", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", - table: "AbpAuditLogActions", - columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "UserId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_AuditLogId", - table: "AbpEntityChanges", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", - table: "AbpEntityChanges", - columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityPropertyChanges_EntityChangeId", - table: "AbpEntityPropertyChanges", - column: "EntityChangeId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", - table: "AbpFeatureValues", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", - table: "AbpLinkUsers", - columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, - unique: true, - filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", - table: "AbpOrganizationUnitRoles", - columns: new[] { "RoleId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_Code", - table: "AbpOrganizationUnits", - column: "Code"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_ParentId", - table: "AbpOrganizationUnits", - column: "ParentId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", - table: "AbpPermissionGrants", - columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[TenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoleClaims_RoleId", - table: "AbpRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoles_NormalizedName", - table: "AbpRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Action", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Action" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_ApplicationName", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "ApplicationName" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Identity", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Identity" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_UserId", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSettings_Name_ProviderName_ProviderKey", - table: "AbpSettings", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpTenants_Name", - table: "AbpTenants", - column: "Name"); - - 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_AbpUserOrganizationUnits_UserId_OrganizationUnitId", - table: "AbpUserOrganizationUnits", - columns: new[] { "UserId", "OrganizationUnitId" }); - - 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: "AbpAuditLogActions"); - - migrationBuilder.DropTable( - name: "AbpClaimTypes"); - - migrationBuilder.DropTable( - name: "AbpEntityPropertyChanges"); - - migrationBuilder.DropTable( - name: "AbpFeatureValues"); + migrationBuilder.DropTable( + name: "AbpAuditLogActions"); + + migrationBuilder.DropTable( + name: "AbpClaimTypes"); + + migrationBuilder.DropTable( + name: "AbpEntityPropertyChanges"); + + migrationBuilder.DropTable( + name: "AbpFeatureValues"); - migrationBuilder.DropTable( - name: "AbpLinkUsers"); + migrationBuilder.DropTable( + name: "AbpLinkUsers"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnitRoles"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); - migrationBuilder.DropTable( - name: "AbpPermissionGrants"); + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); - migrationBuilder.DropTable( - name: "AbpRoleClaims"); + migrationBuilder.DropTable( + name: "AbpRoleClaims"); - migrationBuilder.DropTable( - name: "AbpSecurityLogs"); + migrationBuilder.DropTable( + name: "AbpSecurityLogs"); - migrationBuilder.DropTable( - name: "AbpSettings"); + migrationBuilder.DropTable( + name: "AbpSettings"); - migrationBuilder.DropTable( - name: "AbpTenantConnectionStrings"); + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); - migrationBuilder.DropTable( - name: "AbpUserClaims"); + migrationBuilder.DropTable( + name: "AbpUserClaims"); - migrationBuilder.DropTable( - name: "AbpUserLogins"); + migrationBuilder.DropTable( + name: "AbpUserLogins"); - migrationBuilder.DropTable( - name: "AbpUserOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpUserRoles"); + migrationBuilder.DropTable( + name: "AbpUserRoles"); - migrationBuilder.DropTable( - name: "AbpUserTokens"); + migrationBuilder.DropTable( + name: "AbpUserTokens"); - migrationBuilder.DropTable( - name: "AbpEntityChanges"); + migrationBuilder.DropTable( + name: "AbpEntityChanges"); - migrationBuilder.DropTable( - name: "AbpTenants"); + migrationBuilder.DropTable( + name: "AbpTenants"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpRoles"); + migrationBuilder.DropTable( + name: "AbpRoles"); - migrationBuilder.DropTable( - name: "AbpUsers"); + migrationBuilder.DropTable( + name: "AbpUsers"); - migrationBuilder.DropTable( - name: "AbpAuditLogs"); - } + migrationBuilder.DropTable( + name: "AbpAuditLogs"); } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs index db7b8a3691..ed4f5d13e9 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs @@ -41,152 +41,151 @@ using Volo.Abp.TenantManagement.Web; using Volo.Abp.Threading; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameWebModule), + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameHttpApiModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpAutofacModule), + typeof(AbpAccountWebModule), + typeof(AbpAccountApplicationModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpIdentityWebModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpPermissionManagementDomainIdentityModule), + typeof(AbpFeatureManagementWebModule), + typeof(AbpFeatureManagementApplicationModule), + typeof(AbpFeatureManagementHttpApiModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpTenantManagementWebModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpTenantManagementHttpApiModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) + )] +public class MyProjectNameWebUnifiedModule : AbpModule { - [DependsOn( - typeof(MyProjectNameWebModule), - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameHttpApiModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpAutofacModule), - typeof(AbpAccountWebModule), - typeof(AbpAccountApplicationModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpPermissionManagementHttpApiModule), - typeof(AbpIdentityWebModule), - typeof(AbpIdentityApplicationModule), - typeof(AbpIdentityHttpApiModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpFeatureManagementWebModule), - typeof(AbpFeatureManagementApplicationModule), - typeof(AbpFeatureManagementHttpApiModule), - typeof(AbpFeatureManagementEntityFrameworkCoreModule), - typeof(AbpTenantManagementWebModule), - typeof(AbpTenantManagementApplicationModule), - typeof(AbpTenantManagementHttpApiModule), - typeof(AbpTenantManagementEntityFrameworkCoreModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameWebUnifiedModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); + + Configure(options => { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); + options.UseSqlServer(); + }); - Configure(options => + if (hostingEnvironment.IsDevelopment()) + { + Configure(options => { - options.UseSqlServer(); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain.Shared", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", Path.DirectorySeparatorChar))); }); + } - if (hostingEnvironment.IsDevelopment()) + context.Services.AddAbpSwaggerGen( + options => { - Configure(options => - { - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain.Shared", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", Path.DirectorySeparatorChar))); - }); - } - - context.Services.AddAbpSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); - - Configure(options => - { - options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); - options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); - options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); - options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); - options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); - options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); - options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)")); - options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); - options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); - options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); - options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); - options.Languages.Add(new LanguageInfo("es", "es", "Español")); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - Configure(options => - { - options.IsEnabled = MultiTenancyConsts.IsEnabled; - }); + Configure(options => + { + options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); + options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); + options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); + options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); + options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); + options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); + options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)")); + options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); + options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); + options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); + options.Languages.Add(new LanguageInfo("es", "es", "Español")); + }); + + Configure(options => + { + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); #if DEBUG - context.Services.Replace(ServiceDescriptor.Singleton()); + context.Services.Replace(ServiceDescriptor.Singleton()); #endif - } + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseErrorPage(); - app.UseHsts(); - } + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseErrorPage(); + app.UseHsts(); + } - app.UseHttpsRedirection(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); + app.UseHttpsRedirection(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - app.UseAbpRequestLocalization(); - app.UseAuthorization(); + app.UseAbpRequestLocalization(); + app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); - }); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); + }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); - using (var scope = context.ServiceProvider.CreateScope()) + using (var scope = context.ServiceProvider.CreateScope()) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + }); } } } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml.cs index f6560e1d1c..083ddcb49a 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml.cs @@ -1,11 +1,10 @@ using Microsoft.AspNetCore.Mvc.RazorPages; -namespace MyCompanyName.MyProjectName.Pages +namespace MyCompanyName.MyProjectName.Pages; + +public class IndexModel : PageModel { - public class IndexModel : PageModel + public void OnGet() { - public void OnGet() - { - } } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs index 9e4d072019..6b523328cc 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs @@ -6,47 +6,46 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Debug() - .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.Async(c => c.File("Logs/logs.txt")) + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("Logs/logs.txt")) #if DEBUG .WriteTo.Async(c => c.Console()) #endif .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Startup.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Startup.cs index e48fe56fbc..2be66923ce 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Startup.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Startup.cs @@ -3,18 +3,17 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs index eda0387654..4c35b01f4d 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs @@ -2,15 +2,14 @@ using Volo.Abp.Modularity; using Volo.Abp.Authorization; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameDomainSharedModule), + typeof(AbpDddApplicationContractsModule), + typeof(AbpAuthorizationModule) + )] +public class MyProjectNameApplicationContractsModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainSharedModule), - typeof(AbpDddApplicationContractsModule), - typeof(AbpAuthorizationModule) - )] - public class MyProjectNameApplicationContractsModule : AbpModule - { - } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameRemoteServiceConsts.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameRemoteServiceConsts.cs index fb08e10462..e6b15e95ba 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameRemoteServiceConsts.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameRemoteServiceConsts.cs @@ -1,9 +1,8 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class MyProjectNameRemoteServiceConsts { - public class MyProjectNameRemoteServiceConsts - { - public const string RemoteServiceName = "MyProjectName"; + public const string RemoteServiceName = "MyProjectName"; - public const string ModuleName = "myProjectName"; - } + public const string ModuleName = "myProjectName"; } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs index 2dcf9a68f8..3e6b08c7c7 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs @@ -2,18 +2,17 @@ using Volo.Abp.Authorization.Permissions; using Volo.Abp.Localization; -namespace MyCompanyName.MyProjectName.Permissions +namespace MyCompanyName.MyProjectName.Permissions; + +public class MyProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider { - public class MyProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider + public override void Define(IPermissionDefinitionContext context) { - public override void Define(IPermissionDefinitionContext context) - { - var myGroup = context.AddGroup(MyProjectNamePermissions.GroupName, L("Permission:MyProjectName")); - } + var myGroup = context.AddGroup(MyProjectNamePermissions.GroupName, L("Permission:MyProjectName")); + } - private static LocalizableString L(string name) - { - return LocalizableString.Create(name); - } + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs index 75ecd85ff1..260fbb3679 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs @@ -1,14 +1,13 @@ using Volo.Abp.Reflection; -namespace MyCompanyName.MyProjectName.Permissions +namespace MyCompanyName.MyProjectName.Permissions; + +public class MyProjectNamePermissions { - public class MyProjectNamePermissions - { - public const string GroupName = "MyProjectName"; + public const string GroupName = "MyProjectName"; - public static string[] GetAll() - { - return ReflectionHelper.GetPublicConstantsRecursively(typeof(MyProjectNamePermissions)); - } + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(MyProjectNamePermissions)); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/ISampleAppService.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/ISampleAppService.cs index 206e81bebe..0619f57196 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/ISampleAppService.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/ISampleAppService.cs @@ -1,12 +1,11 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +public interface ISampleAppService : IApplicationService { - public interface ISampleAppService : IApplicationService - { - Task GetAsync(); + Task GetAsync(); - Task GetAuthorizedAsync(); - } + Task GetAuthorizedAsync(); } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/SampleDto.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/SampleDto.cs index ff5f17ef02..25c6c93c83 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/SampleDto.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/SampleDto.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +public class SampleDto { - public class SampleDto - { - public int Value { get; set; } - } -} \ No newline at end of file + public int Value { get; set; } +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs index 71bb06e43f..1c0bde6080 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs @@ -1,14 +1,13 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.Application.Services; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public abstract class MyProjectNameAppService : ApplicationService { - public abstract class MyProjectNameAppService : ApplicationService + protected MyProjectNameAppService() { - protected MyProjectNameAppService() - { - LocalizationResource = typeof(MyProjectNameResource); - ObjectMapperContext = typeof(MyProjectNameApplicationModule); - } + LocalizationResource = typeof(MyProjectNameResource); + ObjectMapperContext = typeof(MyProjectNameApplicationModule); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs index 8b471075de..f3f7d14052 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs @@ -1,14 +1,13 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class MyProjectNameApplicationAutoMapperProfile : Profile { - public class MyProjectNameApplicationAutoMapperProfile : Profile + public MyProjectNameApplicationAutoMapperProfile() { - public MyProjectNameApplicationAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - } + /* You can configure your AutoMapper mapping configuration here. + * Alternatively, you can split your mapping configurations + * into multiple profile classes for a better organization. */ } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs index 457c1bc51b..d8fefafb98 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs @@ -3,23 +3,22 @@ using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.Application; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameDomainModule), + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpDddApplicationModule), + typeof(AbpAutoMapperModule) + )] +public class MyProjectNameApplicationModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainModule), - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpDddApplicationModule), - typeof(AbpAutoMapperModule) - )] - public class MyProjectNameApplicationModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddAutoMapperObjectMapper(); + Configure(options => { - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); - } + options.AddMaps(validate: true); + }); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/Samples/SampleAppService.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/Samples/SampleAppService.cs index f34b7771bd..b2901b5c6d 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/Samples/SampleAppService.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/Samples/SampleAppService.cs @@ -1,29 +1,28 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +public class SampleAppService : MyProjectNameAppService, ISampleAppService { - public class SampleAppService : MyProjectNameAppService, ISampleAppService + public Task GetAsync() { - public Task GetAsync() - { - return Task.FromResult( - new SampleDto - { - Value = 42 - } - ); - } + return Task.FromResult( + new SampleDto + { + Value = 42 + } + ); + } - [Authorize] - public Task GetAuthorizedAsync() - { - return Task.FromResult( - new SampleDto - { - Value = 42 - } - ); - } + [Authorize] + public Task GetAuthorizedAsync() + { + return Task.FromResult( + new SampleDto + { + Value = 42 + } + ); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs index a2a1fbbed3..42d94ec462 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs @@ -1,14 +1,13 @@ using Volo.Abp.AspNetCore.Components.Server.Theming; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.Blazor.Server +namespace MyCompanyName.MyProjectName.Blazor.Server; + +[DependsOn( + typeof(AbpAspNetCoreComponentsServerThemingModule), + typeof(MyProjectNameBlazorModule) + )] +public class MyProjectNameBlazorServerModule : AbpModule { - [DependsOn( - typeof(AbpAspNetCoreComponentsServerThemingModule), - typeof(MyProjectNameBlazorModule) - )] - public class MyProjectNameBlazorServerModule : AbpModule - { - - } -} \ No newline at end of file + +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebAssembly/MyProjectNameBlazorWebAssemblyModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebAssembly/MyProjectNameBlazorWebAssemblyModule.cs index d327a462cb..e705cbabc3 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebAssembly/MyProjectNameBlazorWebAssemblyModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebAssembly/MyProjectNameBlazorWebAssemblyModule.cs @@ -1,15 +1,14 @@ using Volo.Abp.AspNetCore.Components.WebAssembly.Theming; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.Blazor.WebAssembly +namespace MyCompanyName.MyProjectName.Blazor.WebAssembly; + +[DependsOn( + typeof(MyProjectNameBlazorModule), + typeof(MyProjectNameHttpApiClientModule), + typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule) + )] +public class MyProjectNameBlazorWebAssemblyModule : AbpModule { - [DependsOn( - typeof(MyProjectNameBlazorModule), - typeof(MyProjectNameHttpApiClientModule), - typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule) - )] - public class MyProjectNameBlazorWebAssemblyModule : AbpModule - { - - } -} \ No newline at end of file + +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs index 116bffb5aa..08feac2791 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs @@ -1,24 +1,23 @@ using System.Threading.Tasks; using Volo.Abp.UI.Navigation; -namespace MyCompanyName.MyProjectName.Blazor.Menus +namespace MyCompanyName.MyProjectName.Blazor.Menus; + +public class MyProjectNameMenuContributor : IMenuContributor { - public class MyProjectNameMenuContributor : IMenuContributor + public async Task ConfigureMenuAsync(MenuConfigurationContext context) { - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + if (context.Menu.Name == StandardMenus.Main) { - if (context.Menu.Name == StandardMenus.Main) - { - await ConfigureMainMenuAsync(context); - } + await ConfigureMainMenuAsync(context); } + } - private Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - //Add main menu items. - context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "/MyProjectName", icon: "fa fa-globe")); - - return Task.CompletedTask; - } + private Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + //Add main menu items. + context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "/MyProjectName", icon: "fa fa-globe")); + + return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs index 1fd011d0f3..ccca87ae30 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName.Blazor.Menus +namespace MyCompanyName.MyProjectName.Blazor.Menus; + +public class MyProjectNameMenus { - public class MyProjectNameMenus - { - public const string Prefix = "MyProjectName"; + public const string Prefix = "MyProjectName"; - //Add your menu items here... - //public const string Home = Prefix + ".MyNewMenuItem"; + //Add your menu items here... + //public const string Home = Prefix + ".MyNewMenuItem"; - } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs index b3cf8b84b6..13deb63b1d 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs @@ -1,14 +1,13 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +public class MyProjectNameBlazorAutoMapperProfile : Profile { - public class MyProjectNameBlazorAutoMapperProfile : Profile + public MyProjectNameBlazorAutoMapperProfile() { - public MyProjectNameBlazorAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - } + /* You can configure your AutoMapper mapping configuration here. + * Alternatively, you can split your mapping configurations + * into multiple profile classes for a better organization. */ } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs index defe9b65d5..dd7bf654ee 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs @@ -6,33 +6,32 @@ using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +[DependsOn( + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpAspNetCoreComponentsWebThemingModule), + typeof(AbpAutoMapperModule) + )] +public class MyProjectNameBlazorModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpAspNetCoreComponentsWebThemingModule), - typeof(AbpAutoMapperModule) - )] - public class MyProjectNameBlazorModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAutoMapperObjectMapper(); + context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddProfile(validate: true); - }); + Configure(options => + { + options.AddProfile(validate: true); + }); - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor()); - }); + Configure(options => + { + options.MenuContributors.Add(new MyProjectNameMenuContributor()); + }); - Configure(options => - { - options.AdditionalAssemblies.Add(typeof(MyProjectNameBlazorModule).Assembly); - }); - } + Configure(options => + { + options.AdditionalAssemblies.Add(typeof(MyProjectNameBlazorModule).Assembly); + }); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs index 2bf5b0d33c..7c4deb35ab 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs @@ -1,10 +1,9 @@ using Volo.Abp.Localization; -namespace MyCompanyName.MyProjectName.Localization +namespace MyCompanyName.MyProjectName.Localization; + +[LocalizationResourceName("MyProjectName")] +public class MyProjectNameResource { - [LocalizationResourceName("MyProjectName")] - public class MyProjectNameResource - { - - } + } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs index 081ccfb739..26e8c12d42 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs @@ -6,32 +6,31 @@ using Volo.Abp.Validation; using Volo.Abp.Validation.Localization; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpValidationModule) +)] +public class MyProjectNameDomainSharedModule : AbpModule { - [DependsOn( - typeof(AbpValidationModule) - )] - public class MyProjectNameDomainSharedModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + options.FileSets.AddEmbedded(); + }); - Configure(options => - { - options.Resources - .Add("en") - .AddBaseTypes(typeof(AbpValidationResource)) - .AddVirtualJson("/Localization/MyProjectName"); - }); + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/Localization/MyProjectName"); + }); - Configure(options => - { - options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource)); - }); - } + Configure(options => + { + options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource)); + }); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameErrorCodes.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameErrorCodes.cs index 510927a7f1..5851086435 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameErrorCodes.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameErrorCodes.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameErrorCodes { - public static class MyProjectNameErrorCodes - { - //Add your business exception error codes here... - } + //Add your business exception error codes here... } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDbProperties.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDbProperties.cs index f8c73d0653..2ac3e3f9e3 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDbProperties.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDbProperties.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameDbProperties { - public static class MyProjectNameDbProperties - { - public static string DbTablePrefix { get; set; } = "MyProjectName"; + public static string DbTablePrefix { get; set; } = "MyProjectName"; - public static string DbSchema { get; set; } = null; + public static string DbSchema { get; set; } = null; - public const string ConnectionStringName = "MyProjectName"; - } + public const string ConnectionStringName = "MyProjectName"; } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs index 243d35aa91..aae8cc7778 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs @@ -1,14 +1,13 @@ using Volo.Abp.Domain; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpDddDomainModule), + typeof(MyProjectNameDomainSharedModule) +)] +public class MyProjectNameDomainModule : AbpModule { - [DependsOn( - typeof(AbpDddDomainModule), - typeof(MyProjectNameDomainSharedModule) - )] - public class MyProjectNameDomainModule : AbpModule - { - } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs index f82e77b59e..94f87c0674 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs @@ -1,14 +1,13 @@ using Volo.Abp.Settings; -namespace MyCompanyName.MyProjectName.Settings +namespace MyCompanyName.MyProjectName.Settings; + +public class MyProjectNameSettingDefinitionProvider : SettingDefinitionProvider { - public class MyProjectNameSettingDefinitionProvider : SettingDefinitionProvider + public override void Define(ISettingDefinitionContext context) { - public override void Define(ISettingDefinitionContext context) - { - /* Define module settings here. - * Use names from MyProjectNameSettings class. - */ - } + /* Define module settings here. + * Use names from MyProjectNameSettings class. + */ } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs index 08767672ea..027ade5e11 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName.Settings +namespace MyCompanyName.MyProjectName.Settings; + +public static class MyProjectNameSettings { - public static class MyProjectNameSettings - { - public const string GroupName = "MyProjectName"; + public const string GroupName = "MyProjectName"; - /* Add constants for setting names. Example: - * public const string MySettingName = GroupName + ".MySettingName"; - */ - } -} \ No newline at end of file + /* Add constants for setting names. Example: + * public const string MySettingName = GroupName + ".MySettingName"; + */ +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/IMyProjectNameDbContext.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/IMyProjectNameDbContext.cs index f4be3e0eac..4861467071 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/IMyProjectNameDbContext.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/IMyProjectNameDbContext.cs @@ -1,13 +1,12 @@ using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] +public interface IMyProjectNameDbContext : IEfCoreDbContext { - [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] - public interface IMyProjectNameDbContext : IEfCoreDbContext - { - /* Add DbSet for each Aggregate Root here. Example: - * DbSet Questions { get; } - */ - } -} \ No newline at end of file + /* Add DbSet for each Aggregate Root here. Example: + * DbSet Questions { get; } + */ +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs index 1d37924126..97afe2072e 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs @@ -2,26 +2,25 @@ using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] +public class MyProjectNameDbContext : AbpDbContext, IMyProjectNameDbContext { - [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] - public class MyProjectNameDbContext : AbpDbContext, IMyProjectNameDbContext - { - /* Add DbSet for each Aggregate Root here. Example: - * public DbSet Questions { get; set; } - */ + /* Add DbSet for each Aggregate Root here. Example: + * public DbSet Questions { get; set; } + */ - public MyProjectNameDbContext(DbContextOptions options) - : base(options) - { + public MyProjectNameDbContext(DbContextOptions options) + : base(options) + { - } + } - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); - builder.ConfigureMyProjectName(); - } + builder.ConfigureMyProjectName(); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs index d8489151e4..a40164a373 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs @@ -1,34 +1,33 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public static class MyProjectNameDbContextModelCreatingExtensions { - public static class MyProjectNameDbContextModelCreatingExtensions + public static void ConfigureMyProjectName( + this ModelBuilder builder) { - public static void ConfigureMyProjectName( - this ModelBuilder builder) - { - Check.NotNull(builder, nameof(builder)); + Check.NotNull(builder, nameof(builder)); - /* Configure all entities here. Example: + /* Configure all entities here. Example: - builder.Entity(b => - { - //Configure table & schema name - b.ToTable(MyProjectNameDbProperties.DbTablePrefix + "Questions", MyProjectNameDbProperties.DbSchema); + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(MyProjectNameDbProperties.DbTablePrefix + "Questions", MyProjectNameDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - //Properties - b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); + //Properties + b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); - //Relations - b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); + //Relations + b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); - //Indexes - b.HasIndex(q => q.CreationTime); - }); - */ - } + //Indexes + b.HasIndex(q => q.CreationTime); + }); + */ } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs index a79dd328e3..1094ebc3bf 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs @@ -2,22 +2,21 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[DependsOn( + typeof(MyProjectNameDomainModule), + typeof(AbpEntityFrameworkCoreModule) +)] +public class MyProjectNameEntityFrameworkCoreModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainModule), - typeof(AbpEntityFrameworkCoreModule) - )] - public class MyProjectNameEntityFrameworkCoreModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddAbpDbContext(options => { - context.Services.AddAbpDbContext(options => - { /* Add custom repositories here. Example: * options.AddRepository(); */ - }); - } + }); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs index ecf17f49e4..1a8211a60e 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs @@ -3,25 +3,24 @@ using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpHttpClientModule))] +public class MyProjectNameHttpApiClientModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpHttpClientModule))] - public class MyProjectNameHttpApiClientModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddHttpClientProxies( - typeof(MyProjectNameApplicationContractsModule).Assembly, - MyProjectNameRemoteServiceConsts.RemoteServiceName - ); + context.Services.AddHttpClientProxies( + typeof(MyProjectNameApplicationContractsModule).Assembly, + MyProjectNameRemoteServiceConsts.RemoteServiceName + ); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + Configure(options => + { + options.FileSets.AddEmbedded(); + }); - } } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameController.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameController.cs index 699cc3df56..b3f3568e42 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameController.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameController.cs @@ -1,13 +1,12 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Mvc; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public abstract class MyProjectNameController : AbpControllerBase { - public abstract class MyProjectNameController : AbpControllerBase + protected MyProjectNameController() { - protected MyProjectNameController() - { - LocalizationResource = typeof(MyProjectNameResource); - } + LocalizationResource = typeof(MyProjectNameResource); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs index 11d7348806..f31701e2a5 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs @@ -5,29 +5,28 @@ using Volo.Abp.Localization; using Volo.Abp.Modularity; using Microsoft.Extensions.DependencyInjection; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpAspNetCoreMvcModule))] +public class MyProjectNameHttpApiModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpAspNetCoreMvcModule))] - public class MyProjectNameHttpApiModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + PreConfigure(mvcBuilder => { - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameHttpApiModule).Assembly); - }); - } + mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameHttpApiModule).Assembly); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.Resources - .Get() - .AddBaseTypes(typeof(AbpUiResource)); - }); - } + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Samples/SampleController.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Samples/SampleController.cs index b46ebc24e2..9541fb82b8 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Samples/SampleController.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Samples/SampleController.cs @@ -3,32 +3,31 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Volo.Abp; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +[Area(MyProjectNameRemoteServiceConsts.ModuleName)] +[RemoteService(Name = MyProjectNameRemoteServiceConsts.RemoteServiceName)] +[Route("api/MyProjectName/sample")] +public class SampleController : MyProjectNameController, ISampleAppService { - [Area(MyProjectNameRemoteServiceConsts.ModuleName)] - [RemoteService(Name = MyProjectNameRemoteServiceConsts.RemoteServiceName)] - [Route("api/MyProjectName/sample")] - public class SampleController : MyProjectNameController, ISampleAppService - { - private readonly ISampleAppService _sampleAppService; + private readonly ISampleAppService _sampleAppService; - public SampleController(ISampleAppService sampleAppService) - { - _sampleAppService = sampleAppService; - } + public SampleController(ISampleAppService sampleAppService) + { + _sampleAppService = sampleAppService; + } - [HttpGet] - public async Task GetAsync() - { - return await _sampleAppService.GetAsync(); - } + [HttpGet] + public async Task GetAsync() + { + return await _sampleAppService.GetAsync(); + } - [HttpGet] - [Route("authorized")] - [Authorize] - public async Task GetAuthorizedAsync() - { - return await _sampleAppService.GetAsync(); - } + [HttpGet] + [Route("authorized")] + [Authorize] + public async Task GetAuthorizedAsync() + { + return await _sampleAppService.GetAsync(); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerModule.cs index cc0bcb81a9..805342825b 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerModule.cs @@ -2,20 +2,19 @@ using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace MyCompany.MyProjectName +namespace MyCompany.MyProjectName; + +[DependsOn( + typeof(AbpStudioModuleInstallerModule), + typeof(AbpVirtualFileSystemModule) + )] +public class MyProjectNameInstallerModule : AbpModule { - [DependsOn( - typeof(AbpStudioModuleInstallerModule), - typeof(AbpVirtualFileSystemModule) - )] - public class MyProjectNameInstallerModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - } + options.FileSets.AddEmbedded(); + }); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerPipelineBuilder.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerPipelineBuilder.cs index 7d07f90a77..c2106e92d6 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerPipelineBuilder.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerPipelineBuilder.cs @@ -3,15 +3,14 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; using Volo.Abp.Studio.ModuleInstalling; -namespace MyCompany.MyProjectName +namespace MyCompany.MyProjectName; + +[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] +[ExposeServices(typeof(IModuleInstallingPipelineBuilder))] +public class MyProjectNameInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency { - [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] - [ExposeServices(typeof(IModuleInstallingPipelineBuilder))] - public class MyProjectNameInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency + public async Task BuildAsync(ModuleInstallingContext context) { - public async Task BuildAsync(ModuleInstallingContext context) - { - return GetBasePipeline(context); - } + return GetBasePipeline(context); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/IMyProjectNameMongoDbContext.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/IMyProjectNameMongoDbContext.cs index cb1a269091..dfbd4404e8 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/IMyProjectNameMongoDbContext.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/IMyProjectNameMongoDbContext.cs @@ -1,13 +1,12 @@ using Volo.Abp.Data; using Volo.Abp.MongoDB; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] +public interface IMyProjectNameMongoDbContext : IAbpMongoDbContext { - [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] - public interface IMyProjectNameMongoDbContext : IAbpMongoDbContext - { - /* Define mongo collections here. Example: - * IMongoCollection Questions { get; } - */ - } + /* Define mongo collections here. Example: + * IMongoCollection Questions { get; } + */ } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContext.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContext.cs index 82b1f54ea2..0fe4413e65 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContext.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContext.cs @@ -1,20 +1,19 @@ using Volo.Abp.Data; using Volo.Abp.MongoDB; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] +public class MyProjectNameMongoDbContext : AbpMongoDbContext, IMyProjectNameMongoDbContext { - [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)] - public class MyProjectNameMongoDbContext : AbpMongoDbContext, IMyProjectNameMongoDbContext - { - /* Add mongo collections here. Example: - * public IMongoCollection Questions => Collection(); - */ + /* Add mongo collections here. Example: + * public IMongoCollection Questions => Collection(); + */ - protected override void CreateModel(IMongoModelBuilder modelBuilder) - { - base.CreateModel(modelBuilder); + protected override void CreateModel(IMongoModelBuilder modelBuilder) + { + base.CreateModel(modelBuilder); - modelBuilder.ConfigureMyProjectName(); - } + modelBuilder.ConfigureMyProjectName(); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContextExtensions.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContextExtensions.cs index a66e949d4e..cf89270324 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContextExtensions.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContextExtensions.cs @@ -1,14 +1,13 @@ using Volo.Abp; using Volo.Abp.MongoDB; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +public static class MyProjectNameMongoDbContextExtensions { - public static class MyProjectNameMongoDbContextExtensions + public static void ConfigureMyProjectName( + this IMongoModelBuilder builder) { - public static void ConfigureMyProjectName( - this IMongoModelBuilder builder) - { - Check.NotNull(builder, nameof(builder)); - } + Check.NotNull(builder, nameof(builder)); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs index 453806b057..566ebbb20e 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs @@ -2,22 +2,21 @@ using Volo.Abp.Modularity; using Volo.Abp.MongoDB; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[DependsOn( + typeof(MyProjectNameDomainModule), + typeof(AbpMongoDbModule) + )] +public class MyProjectNameMongoDbModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainModule), - typeof(AbpMongoDbModule) - )] - public class MyProjectNameMongoDbModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddMongoDbContext(options => { - context.Services.AddMongoDbContext(options => - { /* Add custom repositories here. Example: * options.AddRepository(); */ - }); - } + }); } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs index 63837ab762..17a5c58a5f 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs @@ -1,24 +1,23 @@ using System.Threading.Tasks; using Volo.Abp.UI.Navigation; -namespace MyCompanyName.MyProjectName.Web.Menus +namespace MyCompanyName.MyProjectName.Web.Menus; + +public class MyProjectNameMenuContributor : IMenuContributor { - public class MyProjectNameMenuContributor : IMenuContributor + public async Task ConfigureMenuAsync(MenuConfigurationContext context) { - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + if (context.Menu.Name == StandardMenus.Main) { - if (context.Menu.Name == StandardMenus.Main) - { - await ConfigureMainMenuAsync(context); - } + await ConfigureMainMenuAsync(context); } + } - private Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - //Add main menu items. - context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "~/MyProjectName", icon: "fa fa-globe")); + private Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + //Add main menu items. + context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "~/MyProjectName", icon: "fa fa-globe")); - return Task.CompletedTask; - } + return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs index 253701a9a6..9d74c17ff8 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName.Web.Menus +namespace MyCompanyName.MyProjectName.Web.Menus; + +public class MyProjectNameMenus { - public class MyProjectNameMenus - { - public const string Prefix = "MyProjectName"; + public const string Prefix = "MyProjectName"; - //Add your menu items here... - //public const string Home = Prefix + ".MyNewMenuItem"; + //Add your menu items here... + //public const string Home = Prefix + ".MyNewMenuItem"; - } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs index 980df394b5..08b573de75 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs @@ -1,14 +1,13 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +public class MyProjectNameWebAutoMapperProfile : Profile { - public class MyProjectNameWebAutoMapperProfile : Profile + public MyProjectNameWebAutoMapperProfile() { - public MyProjectNameWebAutoMapperProfile() - { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ - } + /* You can configure your AutoMapper mapping configuration here. + * Alternatively, you can split your mapping configurations + * into multiple profile classes for a better organization. */ } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index 6580def0ce..9e139a0515 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -10,50 +10,49 @@ using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; using MyCompanyName.MyProjectName.Permissions; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +[DependsOn( + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpAspNetCoreMvcUiThemeSharedModule), + typeof(AbpAutoMapperModule) + )] +public class MyProjectNameWebModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpAspNetCoreMvcUiThemeSharedModule), - typeof(AbpAutoMapperModule) - )] - public class MyProjectNameWebModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource(typeof(MyProjectNameResource), typeof(MyProjectNameWebModule).Assembly); - }); + options.AddAssemblyResource(typeof(MyProjectNameResource), typeof(MyProjectNameWebModule).Assembly); + }); - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameWebModule).Assembly); - }); - } + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameWebModule).Assembly); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor()); - }); + options.MenuContributors.Add(new MyProjectNameMenuContributor()); + }); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + Configure(options => + { + options.FileSets.AddEmbedded(); + }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + context.Services.AddAutoMapperObjectMapper(); + Configure(options => + { + options.AddMaps(validate: true); + }); - Configure(options => - { + Configure(options => + { //Configure authorization. }); - } } } diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectName/Index.cshtml.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectName/Index.cshtml.cs index bb6a7a4da8..df1ed79975 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectName/Index.cshtml.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectName/Index.cshtml.cs @@ -1,9 +1,8 @@ -namespace MyCompanyName.MyProjectName.Web.Pages.MyProjectName +namespace MyCompanyName.MyProjectName.Web.Pages.MyProjectName; + +public class IndexModel : MyProjectNamePageModel { - public class IndexModel : MyProjectNamePageModel + public void OnGet() { - public void OnGet() - { - } } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs index e1470049ac..e0859f1522 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs @@ -1,16 +1,15 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; -namespace MyCompanyName.MyProjectName.Web.Pages +namespace MyCompanyName.MyProjectName.Web.Pages; + +/* Inherit your PageModel classes from this class. + */ +public abstract class MyProjectNamePageModel : AbpPageModel { - /* Inherit your PageModel classes from this class. - */ - public abstract class MyProjectNamePageModel : AbpPageModel + protected MyProjectNamePageModel() { - protected MyProjectNamePageModel() - { - LocalizationResourceType = typeof(MyProjectNameResource); - ObjectMapperContext = typeof(MyProjectNameWebModule); - } + LocalizationResourceType = typeof(MyProjectNameResource); + ObjectMapperContext = typeof(MyProjectNameWebModule); } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs index 79eac9b1ef..94f5f13609 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +/* Inherit from this class for your application layer tests. + * See SampleAppService_Tests for example. + */ +public abstract class MyProjectNameApplicationTestBase : MyProjectNameTestBase { - /* Inherit from this class for your application layer tests. - * See SampleAppService_Tests for example. - */ - public abstract class MyProjectNameApplicationTestBase : MyProjectNameTestBase - { - } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs index ec2398f098..95ba50122b 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs @@ -1,13 +1,12 @@ using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameDomainTestModule) + )] +public class MyProjectNameApplicationTestModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameDomainTestModule) - )] - public class MyProjectNameApplicationTestModule : AbpModule - { - } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppService_Tests.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppService_Tests.cs index 183f8d0063..b8b7422710 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppService_Tests.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppService_Tests.cs @@ -2,29 +2,28 @@ using Shouldly; using Xunit; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +public class SampleAppService_Tests : MyProjectNameApplicationTestBase { - public class SampleAppService_Tests : MyProjectNameApplicationTestBase - { - private readonly ISampleAppService _sampleAppService; + private readonly ISampleAppService _sampleAppService; - public SampleAppService_Tests() - { - _sampleAppService = GetRequiredService(); - } + public SampleAppService_Tests() + { + _sampleAppService = GetRequiredService(); + } - [Fact] - public async Task GetAsync() - { - var result = await _sampleAppService.GetAsync(); - result.Value.ShouldBe(42); - } + [Fact] + public async Task GetAsync() + { + var result = await _sampleAppService.GetAsync(); + result.Value.ShouldBe(42); + } - [Fact] - public async Task GetAuthorizedAsync() - { - var result = await _sampleAppService.GetAuthorizedAsync(); - result.Value.ShouldBe(42); - } + [Fact] + public async Task GetAuthorizedAsync() + { + var result = await _sampleAppService.GetAuthorizedAsync(); + result.Value.ShouldBe(42); } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs index bfda6bdea4..b0a1dadb5c 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +/* Inherit from this class for your domain layer tests. + * See SampleManager_Tests for example. + */ +public abstract class MyProjectNameDomainTestBase : MyProjectNameTestBase { - /* Inherit from this class for your domain layer tests. - * See SampleManager_Tests for example. - */ - public abstract class MyProjectNameDomainTestBase : MyProjectNameTestBase - { - } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs index b45887e4dc..a4be6d894b 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs @@ -1,17 +1,16 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +/* Domain tests are configured to use the EF Core provider. + * You can switch to MongoDB, however your domain tests should be + * database independent anyway. + */ +[DependsOn( + typeof(MyProjectNameEntityFrameworkCoreTestModule) + )] +public class MyProjectNameDomainTestModule : AbpModule { - /* Domain tests are configured to use the EF Core provider. - * You can switch to MongoDB, however your domain tests should be - * database independent anyway. - */ - [DependsOn( - typeof(MyProjectNameEntityFrameworkCoreTestModule) - )] - public class MyProjectNameDomainTestModule : AbpModule - { - - } + } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleManager_Tests.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleManager_Tests.cs index 18757e02ee..24254b2628 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleManager_Tests.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleManager_Tests.cs @@ -1,21 +1,20 @@ using System.Threading.Tasks; using Xunit; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +public class SampleManager_Tests : MyProjectNameDomainTestBase { - public class SampleManager_Tests : MyProjectNameDomainTestBase - { - //private readonly SampleManager _sampleManager; + //private readonly SampleManager _sampleManager; - public SampleManager_Tests() - { - //_sampleManager = GetRequiredService(); - } + public SampleManager_Tests() + { + //_sampleManager = GetRequiredService(); + } - [Fact] - public async Task Method1Async() - { + [Fact] + public async Task Method1Async() + { - } } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs index 13ea29a22f..19dd3faf2b 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +/* This class can be used as a base class for EF Core integration tests, + * while SampleRepository_Tests uses a different approach. + */ +public abstract class MyProjectNameEntityFrameworkCoreTestBase : MyProjectNameTestBase { - /* This class can be used as a base class for EF Core integration tests, - * while SampleRepository_Tests uses a different approach. - */ - public abstract class MyProjectNameEntityFrameworkCoreTestBase : MyProjectNameTestBase - { - } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs index d64ab9df47..8039bd0acf 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs @@ -6,38 +6,37 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[DependsOn( + typeof(MyProjectNameTestBaseModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreSqliteModule) + )] +public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule { - [DependsOn( - typeof(MyProjectNameTestBaseModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreSqliteModule) - )] - public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var sqliteConnection = CreateDatabaseAndGetConnection(); + var sqliteConnection = CreateDatabaseAndGetConnection(); - Configure(options => + Configure(options => + { + options.Configure(abpDbContextConfigurationContext => { - options.Configure(abpDbContextConfigurationContext => - { - abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); - }); + abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); }); - } - - private static SqliteConnection CreateDatabaseAndGetConnection() - { - var connection = new SqliteConnection("Data Source=:memory:"); - connection.Open(); + }); + } + + private static SqliteConnection CreateDatabaseAndGetConnection() + { + var connection = new SqliteConnection("Data Source=:memory:"); + connection.Open(); + + new MyProjectNameDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); - new MyProjectNameDbContext( - new DbContextOptionsBuilder().UseSqlite(connection).Options - ).GetService().CreateTables(); - - return connection; - } + return connection; } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs index 5b2f920052..328abdd392 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs @@ -1,12 +1,11 @@ using MyCompanyName.MyProjectName.Samples; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples +namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples; + +public class SampleRepository_Tests : SampleRepository_Tests { - public class SampleRepository_Tests : SampleRepository_Tests - { - /* Don't write custom repository tests here, instead write to - * the base class. - * One exception can be some specific tests related to EF core. - */ - } + /* Don't write custom repository tests here, instead write to + * the base class. + * One exception can be some specific tests related to EF core. + */ } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs index 7b88d85fc6..5081d8be6c 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs @@ -7,150 +7,149 @@ using MyCompanyName.MyProjectName.Samples; using Volo.Abp.DependencyInjection; using Volo.Abp.IdentityModel; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class ClientDemoService : ITransientDependency { - public class ClientDemoService : ITransientDependency + private readonly ISampleAppService _sampleAppService; + private readonly IIdentityModelAuthenticationService _authenticationService; + private readonly IConfiguration _configuration; + + public ClientDemoService( + ISampleAppService sampleAppService, + IIdentityModelAuthenticationService authenticationService, + IConfiguration configuration) { - private readonly ISampleAppService _sampleAppService; - private readonly IIdentityModelAuthenticationService _authenticationService; - private readonly IConfiguration _configuration; - - public ClientDemoService( - ISampleAppService sampleAppService, - IIdentityModelAuthenticationService authenticationService, - IConfiguration configuration) - { - _sampleAppService = sampleAppService; - _authenticationService = authenticationService; - _configuration = configuration; - } + _sampleAppService = sampleAppService; + _authenticationService = authenticationService; + _configuration = configuration; + } - public async Task RunAsync() - { - await TestWithDynamicProxiesAsync(); - await TestWithHttpClientAndIdentityModelAuthenticationServiceAsync(); - await TestAllManuallyAsync(); - } + public async Task RunAsync() + { + await TestWithDynamicProxiesAsync(); + await TestWithHttpClientAndIdentityModelAuthenticationServiceAsync(); + await TestAllManuallyAsync(); + } - /* Shows how to perform an HTTP request to the API using ABP's dynamic c# proxy - * feature. It is just simple as calling a local service method. - * Authorization and HTTP request details are handled by the ABP framework. - */ - private async Task TestWithDynamicProxiesAsync() - { - Console.WriteLine(); - Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****"); + /* Shows how to perform an HTTP request to the API using ABP's dynamic c# proxy + * feature. It is just simple as calling a local service method. + * Authorization and HTTP request details are handled by the ABP framework. + */ + private async Task TestWithDynamicProxiesAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****"); - var result = await _sampleAppService.GetAsync(); - Console.WriteLine("Result: " + result.Value); + var result = await _sampleAppService.GetAsync(); + Console.WriteLine("Result: " + result.Value); - result = await _sampleAppService.GetAuthorizedAsync(); - Console.WriteLine("Result (authorized): " + result.Value); - } + result = await _sampleAppService.GetAuthorizedAsync(); + Console.WriteLine("Result (authorized): " + result.Value); + } - /* Shows how to use HttpClient to perform a request to the HTTP API. - * It uses ABP's IIdentityModelAuthenticationService to simplify obtaining access tokens. - */ - private async Task TestWithHttpClientAndIdentityModelAuthenticationServiceAsync() + /* Shows how to use HttpClient to perform a request to the HTTP API. + * It uses ABP's IIdentityModelAuthenticationService to simplify obtaining access tokens. + */ + private async Task TestWithHttpClientAndIdentityModelAuthenticationServiceAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestWithHttpClientAndIdentityModelAuthenticationServiceAsync)} *****"); + + //Get access token using ABP's IIdentityModelAuthenticationService + + var accessToken = await _authenticationService.GetAccessTokenAsync( + new IdentityClientConfiguration( + _configuration["IdentityClients:Default:Authority"], + _configuration["IdentityClients:Default:Scope"], + _configuration["IdentityClients:Default:ClientId"], + _configuration["IdentityClients:Default:ClientSecret"], + _configuration["IdentityClients:Default:GrantType"], + _configuration["IdentityClients:Default:UserName"], + _configuration["IdentityClients:Default:UserPassword"] + ) + ); + + //Perform the actual HTTP request + + using (var httpClient = new HttpClient()) { - Console.WriteLine(); - Console.WriteLine($"***** {nameof(TestWithHttpClientAndIdentityModelAuthenticationServiceAsync)} *****"); - - //Get access token using ABP's IIdentityModelAuthenticationService - - var accessToken = await _authenticationService.GetAccessTokenAsync( - new IdentityClientConfiguration( - _configuration["IdentityClients:Default:Authority"], - _configuration["IdentityClients:Default:Scope"], - _configuration["IdentityClients:Default:ClientId"], - _configuration["IdentityClients:Default:ClientSecret"], - _configuration["IdentityClients:Default:GrantType"], - _configuration["IdentityClients:Default:UserName"], - _configuration["IdentityClients:Default:UserPassword"] - ) - ); - - //Perform the actual HTTP request - - using (var httpClient = new HttpClient()) + httpClient.SetBearerToken(accessToken); + + var url = _configuration["RemoteServices:MyProjectName:BaseUrl"] + + "api/MyProjectName/sample/authorized"; + + var responseMessage = await httpClient.GetAsync(url); + if (responseMessage.IsSuccessStatusCode) + { + var responseString = await responseMessage.Content.ReadAsStringAsync(); + Console.WriteLine("Result: " + responseString); + } + else { - httpClient.SetBearerToken(accessToken); - - var url = _configuration["RemoteServices:MyProjectName:BaseUrl"] + - "api/MyProjectName/sample/authorized"; - - var responseMessage = await httpClient.GetAsync(url); - if (responseMessage.IsSuccessStatusCode) - { - var responseString = await responseMessage.Content.ReadAsStringAsync(); - Console.WriteLine("Result: " + responseString); - } - else - { - throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); - } + throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); } } + } + + /* Shows how to use HttpClient to perform a request to the HTTP API. + * It obtains access token using IdentityServer's API. See its documentation: + * https://identityserver4.readthedocs.io/en/latest/quickstarts/2_resource_owner_passwords.html + */ + private async Task TestAllManuallyAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestAllManuallyAsync)} *****"); + + //Obtain access token from the IDS4 server - /* Shows how to use HttpClient to perform a request to the HTTP API. - * It obtains access token using IdentityServer's API. See its documentation: - * https://identityserver4.readthedocs.io/en/latest/quickstarts/2_resource_owner_passwords.html - */ - private async Task TestAllManuallyAsync() + // discover endpoints from metadata + var client = new HttpClient(); + var disco = await client.GetDiscoveryDocumentAsync(_configuration["IdentityClients:Default:Authority"]); + if (disco.IsError) { - Console.WriteLine(); - Console.WriteLine($"***** {nameof(TestAllManuallyAsync)} *****"); + Console.WriteLine(disco.Error); + return; + } - //Obtain access token from the IDS4 server + // request token + var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest + { + Address = disco.TokenEndpoint, + ClientId = _configuration["IdentityClients:Default:ClientId"], + ClientSecret = _configuration["IdentityClients:Default:ClientSecret"], + UserName = _configuration["IdentityClients:Default:UserName"], + Password = _configuration["IdentityClients:Default:UserPassword"], + Scope = _configuration["IdentityClients:Default:Scope"] + }); + + if (tokenResponse.IsError) + { + Console.WriteLine(tokenResponse.Error); + return; + } - // discover endpoints from metadata - var client = new HttpClient(); - var disco = await client.GetDiscoveryDocumentAsync(_configuration["IdentityClients:Default:Authority"]); - if (disco.IsError) - { - Console.WriteLine(disco.Error); - return; - } + Console.WriteLine(tokenResponse.Json); - // request token - var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest - { - Address = disco.TokenEndpoint, - ClientId = _configuration["IdentityClients:Default:ClientId"], - ClientSecret = _configuration["IdentityClients:Default:ClientSecret"], - UserName = _configuration["IdentityClients:Default:UserName"], - Password = _configuration["IdentityClients:Default:UserPassword"], - Scope = _configuration["IdentityClients:Default:Scope"] - }); - - if (tokenResponse.IsError) - { - Console.WriteLine(tokenResponse.Error); - return; - } + //Perform the actual HTTP request - Console.WriteLine(tokenResponse.Json); + using (var httpClient = new HttpClient()) + { + httpClient.SetBearerToken(tokenResponse.AccessToken); - //Perform the actual HTTP request + var url = _configuration["RemoteServices:MyProjectName:BaseUrl"] + + "api/MyProjectName/sample/authorized"; - using (var httpClient = new HttpClient()) + var responseMessage = await httpClient.GetAsync(url); + if (responseMessage.IsSuccessStatusCode) + { + var responseString = await responseMessage.Content.ReadAsStringAsync(); + Console.WriteLine("Result: " + responseString); + } + else { - httpClient.SetBearerToken(tokenResponse.AccessToken); - - var url = _configuration["RemoteServices:MyProjectName:BaseUrl"] + - "api/MyProjectName/sample/authorized"; - - var responseMessage = await httpClient.GetAsync(url); - if (responseMessage.IsSuccessStatusCode) - { - var responseString = await responseMessage.Content.ReadAsStringAsync(); - Console.WriteLine("Result: " + responseString); - } - else - { - throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); - } + throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); } } } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs index b78875d8a7..404248dda8 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs @@ -5,34 +5,33 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; -namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp +namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp; + +public class ConsoleTestAppHostedService : IHostedService { - public class ConsoleTestAppHostedService : IHostedService + private readonly IConfiguration _configuration; + + public ConsoleTestAppHostedService(IConfiguration configuration) { - private readonly IConfiguration _configuration; + _configuration = configuration; + } - public ConsoleTestAppHostedService(IConfiguration configuration) + public async Task StartAsync(CancellationToken cancellationToken) + { + using (var application = AbpApplicationFactory.Create(options => { - _configuration = configuration; - } - - public async Task StartAsync(CancellationToken cancellationToken) + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + })) { - using (var application = AbpApplicationFactory.Create(options=> - { - options.Services.ReplaceConfiguration(_configuration); - options.UseAutofac(); - })) - { - application.Initialize(); + application.Initialize(); - var demo = application.ServiceProvider.GetRequiredService(); - await demo.RunAsync(); + var demo = application.ServiceProvider.GetRequiredService(); + await demo.RunAsync(); - application.Shutdown(); - } + application.Shutdown(); } - - public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } + + public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs index e75d629932..7c0fdbf774 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs @@ -2,15 +2,14 @@ using Volo.Abp.Http.Client.IdentityModel; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(MyProjectNameHttpApiClientModule), + typeof(AbpHttpClientIdentityModelModule) + )] +public class MyProjectNameConsoleApiClientModule : AbpModule { - [DependsOn( - typeof(AbpAutofacModule), - typeof(MyProjectNameHttpApiClientModule), - typeof(AbpHttpClientIdentityModelModule) - )] - public class MyProjectNameConsoleApiClientModule : AbpModule - { - } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs index 2055438bc5..e49e1beec8 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs @@ -3,21 +3,20 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp +namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp; + +class Program { - class Program + static async Task Main(string[] args) { - static async Task Main(string[] args) - { - await CreateHostBuilder(args).RunConsoleAsync(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureServices((hostContext, services) => - { - services.AddHostedService(); - }); + await CreateHostBuilder(args).RunConsoleAsync(); } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoDbFixture.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoDbFixture.cs index 630045b802..6956c5c231 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoDbFixture.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoDbFixture.cs @@ -1,22 +1,21 @@ using System; using Mongo2Go; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +public class MongoDbFixture : IDisposable { - public class MongoDbFixture : IDisposable - { - private static readonly MongoDbRunner MongoDbRunner; - public static readonly string ConnectionString; + private static readonly MongoDbRunner MongoDbRunner; + public static readonly string ConnectionString; - static MongoDbFixture() - { - MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20); - ConnectionString = MongoDbRunner.ConnectionString; - } + static MongoDbFixture() + { + MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20); + ConnectionString = MongoDbRunner.ConnectionString; + } - public void Dispose() - { - MongoDbRunner?.Dispose(); - } + public void Dispose() + { + MongoDbRunner?.Dispose(); } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoTestCollection.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoTestCollection.cs index 42c85760c3..42eaeb71dc 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoTestCollection.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MongoTestCollection.cs @@ -1,10 +1,9 @@ using Xunit; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[CollectionDefinition(Name)] +public class MongoTestCollection : ICollectionFixture { - [CollectionDefinition(Name)] - public class MongoTestCollection : ICollectionFixture - { - public const string Name = "MongoDB Collection"; - } -} \ No newline at end of file + public const string Name = "MongoDB Collection"; +} diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestBase.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestBase.cs index 9752ba8f77..af9576f2c7 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestBase.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestBase.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +/* This class can be used as a base class for MongoDB integration tests, + * while SampleRepository_Tests uses a different approach. + */ +public abstract class MyProjectNameMongoDbTestBase : MyProjectNameTestBase { - /* This class can be used as a base class for MongoDB integration tests, - * while SampleRepository_Tests uses a different approach. - */ - public abstract class MyProjectNameMongoDbTestBase : MyProjectNameTestBase - { - } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestModule.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestModule.cs index d63a023cdf..453e657435 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestModule.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/MyProjectNameMongoDbTestModule.cs @@ -3,25 +3,24 @@ using Volo.Abp.Data; using Volo.Abp.Modularity; using Volo.Abp.Uow; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[DependsOn( + typeof(MyProjectNameTestBaseModule), + typeof(MyProjectNameMongoDbModule) + )] +public class MyProjectNameMongoDbTestModule : AbpModule { - [DependsOn( - typeof(MyProjectNameTestBaseModule), - typeof(MyProjectNameMongoDbModule) - )] - public class MyProjectNameMongoDbTestModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var stringArray = MongoDbFixture.ConnectionString.Split('?'); - var connectionString = stringArray[0].EnsureEndsWith('/') + - "Db_" + - Guid.NewGuid().ToString("N") + "/?" + stringArray[1]; + var stringArray = MongoDbFixture.ConnectionString.Split('?'); + var connectionString = stringArray[0].EnsureEndsWith('/') + + "Db_" + + Guid.NewGuid().ToString("N") + "/?" + stringArray[1]; - Configure(options => - { - options.ConnectionStrings.Default = connectionString; - }); - } + Configure(options => + { + options.ConnectionStrings.Default = connectionString; + }); } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/Samples/SampleRepository_Tests.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/Samples/SampleRepository_Tests.cs index c16c416b2c..f38036a99e 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/Samples/SampleRepository_Tests.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDB/Samples/SampleRepository_Tests.cs @@ -1,14 +1,13 @@ using MyCompanyName.MyProjectName.Samples; using Xunit; -namespace MyCompanyName.MyProjectName.MongoDB.Samples +namespace MyCompanyName.MyProjectName.MongoDB.Samples; + +[Collection(MongoTestCollection.Name)] +public class SampleRepository_Tests : SampleRepository_Tests { - [Collection(MongoTestCollection.Name)] - public class SampleRepository_Tests : SampleRepository_Tests - { - /* Don't write custom repository tests here, instead write to - * the base class. - * One exception can be some specific tests related to MongoDB. - */ - } + /* Don't write custom repository tests here, instead write to + * the base class. + * One exception can be some specific tests related to MongoDB. + */ } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameDataSeedContributor.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameDataSeedContributor.cs index fa7a35ec92..1a591aae7e 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameDataSeedContributor.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameDataSeedContributor.cs @@ -4,30 +4,29 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; using Volo.Abp.MultiTenancy; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class MyProjectNameDataSeedContributor : IDataSeedContributor, ITransientDependency { - public class MyProjectNameDataSeedContributor : IDataSeedContributor, ITransientDependency + private readonly IGuidGenerator _guidGenerator; + private readonly ICurrentTenant _currentTenant; + + public MyProjectNameDataSeedContributor( + IGuidGenerator guidGenerator, ICurrentTenant currentTenant) { - private readonly IGuidGenerator _guidGenerator; - private readonly ICurrentTenant _currentTenant; + _guidGenerator = guidGenerator; + _currentTenant = currentTenant; + } - public MyProjectNameDataSeedContributor( - IGuidGenerator guidGenerator, ICurrentTenant currentTenant) - { - _guidGenerator = guidGenerator; - _currentTenant = currentTenant; - } + public Task SeedAsync(DataSeedContext context) + { + /* Instead of returning the Task.CompletedTask, you can insert your test data + * at this point! + */ - public Task SeedAsync(DataSeedContext context) + using (_currentTenant.Change(context?.TenantId)) { - /* Instead of returning the Task.CompletedTask, you can insert your test data - * at this point! - */ - - using (_currentTenant.Change(context?.TenantId)) - { - return Task.CompletedTask; - } + return Task.CompletedTask; } } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs index fcf6e3ffc6..40f9052ac8 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs @@ -6,54 +6,53 @@ using Volo.Abp.Modularity; using Volo.Abp.Uow; using Volo.Abp.Testing; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +/* All test classes are derived from this class, directly or indirectly. */ +public abstract class MyProjectNameTestBase : AbpIntegratedTest + where TStartupModule : IAbpModule { - /* All test classes are derived from this class, directly or indirectly. */ - public abstract class MyProjectNameTestBase : AbpIntegratedTest - where TStartupModule : IAbpModule + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) { - protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) - { - options.UseAutofac(); - } + options.UseAutofac(); + } - protected virtual Task WithUnitOfWorkAsync(Func func) - { - return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); - } + protected virtual Task WithUnitOfWorkAsync(Func func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } - protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + { + using (var scope = ServiceProvider.CreateScope()) { - using (var scope = ServiceProvider.CreateScope()) - { - var uowManager = scope.ServiceProvider.GetRequiredService(); + var uowManager = scope.ServiceProvider.GetRequiredService(); - using (var uow = uowManager.Begin(options)) - { - await action(); + using (var uow = uowManager.Begin(options)) + { + await action(); - await uow.CompleteAsync(); - } + await uow.CompleteAsync(); } } + } - protected virtual Task WithUnitOfWorkAsync(Func> func) - { - return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); - } + protected virtual Task WithUnitOfWorkAsync(Func> func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } - protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + { + using (var scope = ServiceProvider.CreateScope()) { - using (var scope = ServiceProvider.CreateScope()) + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) { - var uowManager = scope.ServiceProvider.GetRequiredService(); - - using (var uow = uowManager.Begin(options)) - { - var result = await func(); - await uow.CompleteAsync(); - return result; - } + var result = await func(); + await uow.CompleteAsync(); + return result; } } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs index dc9082caa6..dcfdbfbe2c 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs @@ -6,37 +6,36 @@ using Volo.Abp.Data; using Volo.Abp.Modularity; using Volo.Abp.Threading; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpTestBaseModule), + typeof(AbpAuthorizationModule), + typeof(MyProjectNameDomainModule) + )] +public class MyProjectNameTestBaseModule : AbpModule { - [DependsOn( - typeof(AbpAutofacModule), - typeof(AbpTestBaseModule), - typeof(AbpAuthorizationModule), - typeof(MyProjectNameDomainModule) - )] - public class MyProjectNameTestBaseModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAlwaysAllowAuthorization(); - } + context.Services.AddAlwaysAllowAuthorization(); + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - SeedTestData(context); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + SeedTestData(context); + } - private static void SeedTestData(ApplicationInitializationContext context) + private static void SeedTestData(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => + using (var scope = context.ServiceProvider.CreateScope()) { - using (var scope = context.ServiceProvider.CreateScope()) - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - } - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + } + }); } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Samples/SampleRepository_Tests.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Samples/SampleRepository_Tests.cs index 09409e4561..738c202b90 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Samples/SampleRepository_Tests.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Samples/SampleRepository_Tests.cs @@ -2,26 +2,25 @@ using Volo.Abp.Modularity; using Xunit; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +/* Write your custom repository tests like that, in this project, as abstract classes. + * Then inherit these abstract classes from EF Core & MongoDB test projects. + * In this way, both database providers are tests with the same set tests. + */ +public abstract class SampleRepository_Tests : MyProjectNameTestBase + where TStartupModule : IAbpModule { - /* Write your custom repository tests like that, in this project, as abstract classes. - * Then inherit these abstract classes from EF Core & MongoDB test projects. - * In this way, both database providers are tests with the same set tests. - */ - public abstract class SampleRepository_Tests : MyProjectNameTestBase - where TStartupModule : IAbpModule - { - //private readonly ISampleRepository _sampleRepository; + //private readonly ISampleRepository _sampleRepository; - protected SampleRepository_Tests() - { - //_sampleRepository = GetRequiredService(); - } + protected SampleRepository_Tests() + { + //_sampleRepository = GetRequiredService(); + } - [Fact] - public async Task Method1Async() - { + [Fact] + public async Task Method1Async() + { - } } } diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs index 5e6b064875..717ba2c324 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs @@ -3,41 +3,40 @@ using System.Security.Claims; using Volo.Abp.DependencyInjection; using Volo.Abp.Security.Claims; -namespace MyCompanyName.MyProjectName.Security +namespace MyCompanyName.MyProjectName.Security; + +[Dependency(ReplaceServices = true)] +public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor { - [Dependency(ReplaceServices = true)] - public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor + protected override ClaimsPrincipal GetClaimsPrincipal() { - protected override ClaimsPrincipal GetClaimsPrincipal() - { - return GetPrincipal(); - } + return GetPrincipal(); + } - private ClaimsPrincipal _principal; + private ClaimsPrincipal _principal; - private ClaimsPrincipal GetPrincipal() + private ClaimsPrincipal GetPrincipal() + { + if (_principal == null) { - if (_principal == null) + lock (this) { - lock (this) + if (_principal == null) { - if (_principal == null) - { - _principal = new ClaimsPrincipal( - new ClaimsIdentity( - new List - { + _principal = new ClaimsPrincipal( + new ClaimsIdentity( + new List + { new Claim(AbpClaimTypes.UserId,"2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), new Claim(AbpClaimTypes.UserName,"admin"), new Claim(AbpClaimTypes.Email,"admin@abp.io") - } - ) - ); - } + } + ) + ); } } - - return _principal; } + + return _principal; } }