Set up multi-project solution with DbFirst API, Application, Domain, and Infrastructure layers. Implemented database-first EF Core for the Catalog entity, including domain, DTOs, repository, service, and controller. Configured AutoMapper, DI, Swagger, and project settings. Added .gitattributes and initial configuration files.
57 lines
1.8 KiB
C#
57 lines
1.8 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<TbmyCatalog> TbmyCatalogs { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<TbmyCatalog>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Guid);
|
|
|
|
entity.ToTable("TBMY_CATALOG");
|
|
|
|
entity.HasIndex(e => e.CatTitle, "UQ_TBMY_CATALOG_TITLE").IsUnique();
|
|
|
|
entity.Property(e => e.Guid).HasColumnName("GUID");
|
|
entity.Property(e => e.AddedWhen)
|
|
.HasDefaultValueSql("(getdate())")
|
|
.HasColumnType("datetime")
|
|
.HasColumnName("ADDED_WHEN");
|
|
entity.Property(e => e.AddedWho)
|
|
.HasMaxLength(30)
|
|
.IsUnicode(false)
|
|
.HasDefaultValue("SYSTEM")
|
|
.HasColumnName("ADDED_WHO");
|
|
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);
|
|
}
|