Update DbTriggerParams and EF Core package versions
- Changed DbTriggerParams to use ICollection<string> for flexibility. - Updated Microsoft.EntityFrameworkCore.SqlServer to version 9.0.6. - Made _logger in EGDbContext nullable and optional in constructor. - Updated logging statements to prevent null reference exceptions. - Added Microsoft.EntityFrameworkCore.SqlServer package for net8.0 and net9.0. - Introduced appsettings.migration.json for connection strings and trigger parameters. - Added EGDbContextFactory for design-time DbContext creation.
This commit is contained in:
@@ -59,9 +59,9 @@ public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
|
||||
|
||||
private readonly DbTriggerParams _triggers;
|
||||
|
||||
private readonly ILogger<EGDbContext> _logger;
|
||||
private readonly ILogger<EGDbContext>? _logger;
|
||||
|
||||
public EGDbContext(DbContextOptions<EGDbContext> options, IOptions<DbTriggerParams> triggerParamOptions, ILogger<EGDbContext> logger) : base(options)
|
||||
public EGDbContext(DbContextOptions<EGDbContext> options, IOptions<DbTriggerParams> triggerParamOptions, ILogger<EGDbContext>? logger = null) : base(options)
|
||||
{
|
||||
_triggers = triggerParamOptions.Value;
|
||||
_logger = logger;
|
||||
@@ -151,7 +151,7 @@ public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
|
||||
.ForEach(tName =>
|
||||
{
|
||||
modelBuilder.Entity<T>().ToTable(tb => tb.HasTrigger(tName));
|
||||
_logger.LogInformation("Trigger '{triggerName}' has been added to the '{entityName}' entity.", tName, typeof(T).Name);
|
||||
_logger?.LogInformation("Trigger '{triggerName}' has been added to the '{entityName}' entity.", tName, typeof(T).Name);
|
||||
});
|
||||
|
||||
// TODO: call add trigger methods with attributes and reflection
|
||||
|
||||
Reference in New Issue
Block a user