Browse Source
Use separate appsettings for MongoDb
pull/17326/head
Enis Necipoglu
3 years ago
No known key found for this signature in database
GPG Key ID: 1EC55E13241E1680
5 changed files with
16 additions and
3 deletions
-
modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs
-
modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs
-
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Program.cs
-
modules/cms-kit/host/Volo.CmsKit.Web.Unified/appsettings.MongoDB.json
-
modules/cms-kit/host/Volo.CmsKit.Web.Unified/appsettings.json
|
|
|
@ -120,6 +120,7 @@ public class CmsKitWebUnifiedModule : AbpModule |
|
|
|
ConfigureCmsKit(); |
|
|
|
|
|
|
|
#if EntityFrameworkCore
|
|
|
|
context.Services.AddDbContext<UnifiedDbContext>(); |
|
|
|
Configure<AbpDbContextOptions>(options => |
|
|
|
{ |
|
|
|
options.UseSqlServer(); |
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Volo.Abp.AuditLogging.EntityFrameworkCore; |
|
|
|
using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|
|
|
using Volo.Abp.Identity.EntityFrameworkCore; |
|
|
|
@ -11,7 +12,6 @@ using Volo.Abp.TenantManagement.EntityFrameworkCore; |
|
|
|
|
|
|
|
namespace Volo.CmsKit.EntityFrameworkCore; |
|
|
|
|
|
|
|
[ConnectionStringName("SqlServerDefault")] |
|
|
|
public class UnifiedDbContext : AbpDbContext<UnifiedDbContext> |
|
|
|
{ |
|
|
|
public UnifiedDbContext(DbContextOptions<UnifiedDbContext> options) |
|
|
|
|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.IO; |
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
using Serilog; |
|
|
|
using Serilog.Events; |
|
|
|
@ -38,6 +39,13 @@ public class Program |
|
|
|
|
|
|
|
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|
|
|
Host.CreateDefaultBuilder(args) |
|
|
|
.AddAppSettingsSecretsJson() |
|
|
|
#if MongoDB
|
|
|
|
.ConfigureAppConfiguration(options => |
|
|
|
{ |
|
|
|
options.AddJsonFile("appsettings.MongoDB.json"); |
|
|
|
}) |
|
|
|
#endif
|
|
|
|
.ConfigureWebHostDefaults(webBuilder => |
|
|
|
{ |
|
|
|
webBuilder.UseStartup<Startup>(); |
|
|
|
|
|
|
|
@ -0,0 +1,5 @@ |
|
|
|
{ |
|
|
|
"ConnectionStrings": { |
|
|
|
"Default": "mongodb://localhost:27017/CmsKit_Unified" |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
{ |
|
|
|
"ConnectionStrings": { |
|
|
|
"SqlServerDefault": "Server=(localdb)\\MSSQLLocalDB;Database=CmsKit_Unified;Trusted_Connection=True;TrustServerCertificate=True", |
|
|
|
"Default": "mongodb://localhost:27017/CmsKit_Unified" |
|
|
|
"Default": "Server=(localdb)\\MSSQLLocalDB;Database=CmsKit_Unified;Trusted_Connection=True;TrustServerCertificate=True" |
|
|
|
} |
|
|
|
} |
|
|
|
|