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:
@@ -3,14 +3,14 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Email.Data;
|
||||
|
||||
public sealed class EmailApiDbContext : DbContext
|
||||
public sealed class EmailDbContext : DbContext
|
||||
{
|
||||
public const string SchemaName = MigrationConstants.SchemaName;
|
||||
public const string MigrationTableName = MigrationConstants.MigrationTableName;
|
||||
|
||||
public EmailApiDbContext(DbContextOptions<EmailApiDbContext> options) : base(options) { }
|
||||
public EmailDbContext(DbContextOptions<EmailDbContext> options) : base(options) { }
|
||||
|
||||
public DbSet<EmailTemplateEntity> EmailTemplates => Set<EmailTemplateEntity>();
|
||||
public DbSet<EmailTemplateEntity> Templates => Set<EmailTemplateEntity>();
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ public sealed class EmailApiDbContext : DbContext
|
||||
|
||||
modelBuilder.Entity<EmailTemplateEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("EmailTemplates");
|
||||
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);
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Email.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Schema constants used by EmailApiDbContext and migrations.
|
||||
/// Schema constants used by EmailDbContext and migrations.
|
||||
/// Centralized to avoid hardcoded strings and ensure consistency.
|
||||
/// </summary>
|
||||
public static class MigrationConstants
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Email.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(EmailApiDbContext))]
|
||||
[DbContext(typeof(EmailDbContext))]
|
||||
[Migration("20260528100000_CreateEmailTemplates")]
|
||||
partial class CreateEmailTemplates
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Email.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(EmailApiDbContext))]
|
||||
[DbContext(typeof(EmailDbContext))]
|
||||
[Migration("20260528130652_SeedEmailTemplates")]
|
||||
partial class SeedEmailTemplates
|
||||
{
|
||||
|
||||
+3
-3
@@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Email.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(EmailApiDbContext))]
|
||||
partial class EmailApiDbContextModelSnapshot : ModelSnapshot
|
||||
[DbContext(typeof(EmailDbContext))]
|
||||
partial class EmailDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace Email.Data.Migrations
|
||||
|
||||
b.HasKey("Key", "Language");
|
||||
|
||||
b.ToTable("EmailTemplates", MigrationConstants.SchemaName);
|
||||
b.ToTable("Templates", MigrationConstants.SchemaName);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
@@ -6,13 +6,13 @@ namespace Email.Data.Repositories;
|
||||
|
||||
public sealed class EfEmailTemplateRepository : IEmailTemplateRepository
|
||||
{
|
||||
private readonly EmailApiDbContext _db;
|
||||
private readonly EmailDbContext _db;
|
||||
|
||||
public EfEmailTemplateRepository(EmailApiDbContext db)
|
||||
public EfEmailTemplateRepository(EmailDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<EmailTemplateEntity>> GetAllAsync(CancellationToken ct)
|
||||
=> await _db.EmailTemplates.AsNoTracking().ToListAsync(ct);
|
||||
=> await _db.Templates.AsNoTracking().ToListAsync(ct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user