Files
DbFirst/DbFirst.Infrastructure/ApplicationDbContext.cs
OlgunR ccd97fe9d6 Refactor catalog CRUD to use stored procedures only
Removed direct usage of TbmyCatalog entity and DbSet. All create, update, and delete operations now use stored procedures. Entity lookups and mappings are performed via the VwmyCatalog view. Updated AutoMapper profile and DbContext configuration accordingly. Catalog creation now sets ChangedWho/ChangedWhen to "system" and current UTC time.
2026-01-14 12:50:58 +01:00

53 lines
1.7 KiB
C#

using DbFirst.Infrastructure.ScaffoldEntities;
using Microsoft.EntityFrameworkCore;
namespace DbFirst.Infrastructure;
public partial class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public virtual DbSet<VwmyCatalog> VwmyCatalogs { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<VwmyCatalog>(entity =>
{
entity.HasKey(e => e.Guid);
entity.ToView("VWMY_CATALOG");
entity.Property(e => e.Guid).HasColumnName("GUID");
entity.Property(e => e.AddedWho)
.HasMaxLength(30)
.IsUnicode(false)
.HasColumnName("ADDED_WHO");
entity.Property(e => e.AddedWhen)
.HasColumnType("datetime")
.HasColumnName("ADDED_WHEN");
entity.Property(e => e.CatString)
.HasMaxLength(900)
.IsUnicode(false)
.HasColumnName("CAT_STRING");
entity.Property(e => e.CatTitle)
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnName("CAT_TITLE");
entity.Property(e => e.ChangedWhen)
.HasColumnType("datetime")
.HasColumnName("CHANGED_WHEN");
entity.Property(e => e.ChangedWho)
.HasMaxLength(30)
.IsUnicode(false)
.HasColumnName("CHANGED_WHO");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}