Ignore EF Core pending model changes warnings and update Oracle DSN.
Added configuration to suppress EF Core PendingModelChangesWarning for better compatibility with newer .NET versions. Updated Oracle connection string to use "localhost" for consistency and clarity in appsettings.json.
This commit is contained in:
parent
26e2b1fb56
commit
006e0bbbb4
|
|
@ -13,7 +13,7 @@
|
|||
"Sqlite": "Data Source=App_Data/elsa.sqlite.db;Cache=Shared;",
|
||||
"MySql": "Server=localhost;Database=elsa;Uid=admin;Pwd=password;",
|
||||
"PostgreSql": "Server=localhost;Username=elsa;Database=elsa;Port=5432;Password=elsa;SSLMode=Prefer;MaxPoolSize=2000;Timeout=60",
|
||||
"Oracle": "User Id=SYSTEM;Password=elsa;Data Source=oracle:1521/ORCLPDB1",
|
||||
"Oracle": "User Id=SYSTEM;Password=elsa;Data Source=localhost:1521/FREE;",
|
||||
"CockroachDb": "Host=localhost;Port=26257;Database=elsa;SslMode=Disable;Username=root;IncludeErrorDetail=true",
|
||||
"MongoDb": "mongodb://localhost:27017/elsa-workflows",
|
||||
"AzureServiceBus": "",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using Elsa.Common.Entities;
|
|||
using Elsa.Common.Multitenancy;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore;
|
||||
|
|
@ -16,7 +17,7 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
|
|||
EntityState.Added,
|
||||
EntityState.Modified,
|
||||
};
|
||||
|
||||
|
||||
protected readonly IServiceProvider ServiceProvider;
|
||||
public string? TenantId { get; set; }
|
||||
|
||||
|
|
@ -43,14 +44,14 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
|
|||
|
||||
// ReSharper disable once VirtualMemberCallInConstructor
|
||||
Schema = !string.IsNullOrWhiteSpace(elsaDbContextOptions?.SchemaName) ? elsaDbContextOptions.SchemaName : ElsaSchema;
|
||||
|
||||
|
||||
var tenantAccessor = serviceProvider.GetService<ITenantAccessor>();
|
||||
var tenantId = tenantAccessor?.Tenant?.Id;
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(tenantId))
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tenantId))
|
||||
TenantId = tenantId;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
|
@ -58,6 +59,13 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
|
|||
return await base.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
#if NET9_0_OR_GREATER
|
||||
optionsBuilder.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
|
@ -66,7 +74,7 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
|
|||
if (!Database.IsSqlite())
|
||||
modelBuilder.HasDefaultSchema(Schema);
|
||||
}
|
||||
|
||||
|
||||
var entityTypeHandlers = ServiceProvider.GetServices<IEntityModelCreatingHandler>().ToList();
|
||||
|
||||
foreach (var entityType in modelBuilder.Model.GetEntityTypes().ToList())
|
||||
|
|
@ -77,7 +85,7 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task OnBeforeSavingAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var handlers = ServiceProvider.GetServices<IEntitySavingHandler>().ToList();
|
||||
|
|
|
|||
Loading…
Reference in a new issue