Creation of EF Core Migrations - these execute using EF Tools, but are not integrated to run programmatically
This commit is contained in:
		| @ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http; | ||||
| using Microsoft.AspNetCore.Identity; | ||||
| using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Oqtane.Extensions; | ||||
| using Oqtane.Models; | ||||
|  | ||||
| @ -13,11 +14,13 @@ namespace Oqtane.Repository | ||||
|     { | ||||
|         private ITenantResolver _tenantResolver; | ||||
|         private IHttpContextAccessor _accessor; | ||||
|         private readonly IConfiguration _configuration; | ||||
|  | ||||
|         public DBContextBase(ITenantResolver tenantResolver, IHttpContextAccessor accessor) | ||||
|         public DBContextBase(ITenantResolver tenantResolver, IHttpContextAccessor accessor, IConfiguration configuration) | ||||
|         { | ||||
|             _tenantResolver = tenantResolver; | ||||
|             _accessor = accessor; | ||||
|             _configuration = configuration; | ||||
|         } | ||||
|  | ||||
|         protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||||
| @ -29,6 +32,17 @@ namespace Oqtane.Repository | ||||
|                     .Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString()); | ||||
|                 optionsBuilder.UseOqtaneDatabase(connectionString); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 if (!String.IsNullOrEmpty(_configuration.GetConnectionString("DefaultConnection"))) | ||||
|                 { | ||||
|                     var connectionString = _configuration.GetConnectionString("DefaultConnection") | ||||
|                         .Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString()); | ||||
|  | ||||
|                     optionsBuilder.UseOqtaneDatabase(connectionString); | ||||
|                 } | ||||
|  | ||||
|             } | ||||
|             base.OnConfiguring(optionsBuilder); | ||||
|         } | ||||
|  | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| using Microsoft.AspNetCore.Http; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Oqtane.Models; | ||||
|  | ||||
| namespace Oqtane.Repository | ||||
| @ -23,7 +24,7 @@ namespace Oqtane.Repository | ||||
|  | ||||
|         public virtual DbSet<Language> Language { get; set; } | ||||
|  | ||||
|         public TenantDBContext(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor) | ||||
|         public TenantDBContext(ITenantResolver tenantResolver, IHttpContextAccessor accessor, IConfiguration configuration) : base(tenantResolver, accessor, configuration) | ||||
|         { | ||||
|             // DBContextBase handles multi-tenant database connections | ||||
|         } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Charles Nurse
					Charles Nurse