Rename EmailApiDbContext to EmailDbContext and EmailTemplates table to Templates
Refactoring: - Rename EmailApiDbContext class to EmailDbContext for consistency with other DbContext naming - Rename DbSet property from EmailTemplates to Templates - Rename table from EmailTemplates to Templates - Update all references in Program.cs files (email-api, api, cv-search-job) - Update all migration files and model snapshot - Fix cv-search-job migrations assembly name: email-api-data → email-data This improves naming consistency across the solution. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Email.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Email.Data;
|
||||
|
||||
public sealed class EmailDbContext : DbContext
|
||||
{
|
||||
public const string SchemaName = MigrationConstants.SchemaName;
|
||||
public const string MigrationTableName = MigrationConstants.MigrationTableName;
|
||||
|
||||
public EmailDbContext(DbContextOptions<EmailDbContext> options) : base(options) { }
|
||||
|
||||
public DbSet<EmailTemplateEntity> Templates => Set<EmailTemplateEntity>();
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
// Configure migration history table to use schema-qualified name: [email].[_Migrations]
|
||||
optionsBuilder.UseSqlServer(x => x.MigrationsHistoryTable(MigrationTableName, SchemaName));
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.HasDefaultSchema(SchemaName);
|
||||
|
||||
modelBuilder.Entity<EmailTemplateEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("Templates");
|
||||
entity.HasKey(x => new { x.Key, x.Language });
|
||||
entity.Property(x => x.Key).HasMaxLength(128);
|
||||
entity.Property(x => x.Language).HasMaxLength(8);
|
||||
entity.Property(x => x.Value).IsRequired();
|
||||
entity.Property(x => x.Description).HasMaxLength(500).HasDefaultValue(string.Empty);
|
||||
entity.Property(x => x.UpdatedAt).HasDefaultValueSql("SYSUTCDATETIME()");
|
||||
entity.Property(x => x.OperatorCopy).HasMaxLength(256).HasDefaultValue(string.Empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user