From a24cb580c8c3079a70647bed9b230e3f028f963d Mon Sep 17 00:00:00 2001 From: Jason Sylvestre Date: Tue, 9 Apr 2024 09:23:11 -0700 Subject: [PATCH 1/4] Remove COA Detail from code --- Finjector.Core/Data/AppDbContext.cs | 3 - Finjector.Core/Domain/Coa.cs | 1 - Finjector.Core/Domain/CoaDetail.cs | 80 ------------------- Finjector.Core/Extensions/StringExtensions.cs | 43 ---------- Finjector.Web/Controllers/ChartsController.cs | 10 --- 5 files changed, 137 deletions(-) delete mode 100644 Finjector.Core/Domain/CoaDetail.cs diff --git a/Finjector.Core/Data/AppDbContext.cs b/Finjector.Core/Data/AppDbContext.cs index 9cc2f98b..c6c7e6c0 100644 --- a/Finjector.Core/Data/AppDbContext.cs +++ b/Finjector.Core/Data/AppDbContext.cs @@ -31,13 +31,10 @@ protected AppDbContext(DbContextOptions options) : base(options) public virtual DbSet Teams { get; set; } = null!; public virtual DbSet TeamPermissions { get; set; } = null!; - public virtual DbSet CoaDetails { get; set; } = null!; - protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); Coa.OnModelCreating(builder); - CoaDetail.OnModelCreating(builder); Folder.OnModelCreating(builder); FolderPermission.OnModelCreating(builder); Team.OnModelCreating(builder); diff --git a/Finjector.Core/Domain/Coa.cs b/Finjector.Core/Domain/Coa.cs index 2eee7ef9..b5098830 100644 --- a/Finjector.Core/Domain/Coa.cs +++ b/Finjector.Core/Domain/Coa.cs @@ -24,7 +24,6 @@ public class Coa [Required] [MaxLength(128)] //Actually 70 I think, but a little play... public string SegmentString { get; set; } = string.Empty; - public CoaDetail Detail { get; set; } = null!; [MaxLength(3)] public string ChartType { get; set; } = string.Empty; diff --git a/Finjector.Core/Domain/CoaDetail.cs b/Finjector.Core/Domain/CoaDetail.cs deleted file mode 100644 index 8e03fc67..00000000 --- a/Finjector.Core/Domain/CoaDetail.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; - -namespace Finjector.Core.Domain -{ - public class CoaDetail - { - [Key] - [MaxLength(128)] - public string Id { get; set; } = string.Empty; //This is the segment string in the Coa table - - [MaxLength(3)] - public string ChartType { get; set; } = string.Empty; - - [MaxLength(4)] - public string Entity { get; set; } = string.Empty; - [MaxLength(50)] - public string EntityDetails { get; set; } = string.Empty; - - [MaxLength(5)] - public string Fund { get; set; } = string.Empty; - [MaxLength(50)] - public string FundDetails { get; set; } = string.Empty; - - [MaxLength(7)] - public string Department { get; set; } = string.Empty; //And PPM Org - [MaxLength(50)] - public string DepartmentDetails { get; set; } = string.Empty; - - [MaxLength(2)] - public string Purpose { get; set; } = string.Empty; - [MaxLength(50)] - public string PurposeDetails { get; set; } = string.Empty; - - [MaxLength(6)] - public string NaturalAccount { get; set; } = string.Empty; //And Expenditure Type - [MaxLength(50)] - public string NaturalAccountDetails { get; set; } = string.Empty; - - [MaxLength(10)] - public string Project { get; set; } = string.Empty; - [MaxLength(50)] - public string ProjectDetails { get; set; } = string.Empty; - - [MaxLength(3)] - public string Program { get; set; } = string.Empty; - [MaxLength(50)] - public string ProgramDetails { get; set; } = string.Empty; - - [MaxLength(6)] - public string Activity { get; set; } = string.Empty; - [MaxLength(50)] - public string ActivityDetails { get; set; } = string.Empty; - - [MaxLength(6)] - public string Task { get; set; } = string.Empty; - [MaxLength(50)] - public string TaskDetails { get; set; } = string.Empty; - - [JsonIgnore] - public ICollection Coas { get; set; } = new List(); - - internal static void OnModelCreating(ModelBuilder modelBuilder) - { - //CoaDetail can have many Coa's abd the Coa's have one CoaDetail with the segment string as the key - modelBuilder.Entity() - .HasMany(c => c.Coas) - .WithOne(c => c.Detail) - .HasForeignKey(c => c.SegmentString) - .OnDelete(DeleteBehavior.Restrict); - } - - } -} diff --git a/Finjector.Core/Extensions/StringExtensions.cs b/Finjector.Core/Extensions/StringExtensions.cs index f3ffafec..0ed8e0ea 100644 --- a/Finjector.Core/Extensions/StringExtensions.cs +++ b/Finjector.Core/Extensions/StringExtensions.cs @@ -31,48 +31,5 @@ public static string ToUpperTrim(this string value) return value.Trim().ToUpper(); } - /// - /// Return segmented detail values from a CoA string - /// - /// Should be either a PPM or GL string - /// - public static CoaDetail ToCoADetail(this string value) - { - var chartType = FinancialChartValidation.GetFinancialChartStringType(value); - - if (chartType == FinancialChartStringType.Invalid) - { - return new CoaDetail(); - } - - var rtValue = new CoaDetail() - { - Id = value, - ChartType = chartType == FinancialChartStringType.Ppm ? Coa.ChartTypes.PPM : Coa.ChartTypes.GL - }; - - if (chartType == FinancialChartStringType.Ppm) - { - var parts = value.Split('-'); - rtValue.Project = parts[0]; - rtValue.Task = parts[1]; - rtValue.Department = parts[2]; - rtValue.NaturalAccount = parts[3]; - } - if (chartType == FinancialChartStringType.Gl) - { - var parts = value.Split('-'); - rtValue.Entity = parts[0]; - rtValue.Fund = parts[1]; - rtValue.Department = parts[2]; - rtValue.NaturalAccount = parts[3]; - rtValue.Purpose = parts[4]; - rtValue.Program = parts[5]; - rtValue.Project = parts[6]; - rtValue.Activity = parts[7]; - } - - return rtValue; - } } } diff --git a/Finjector.Web/Controllers/ChartsController.cs b/Finjector.Web/Controllers/ChartsController.cs index d56cc7ad..dc72a3d9 100644 --- a/Finjector.Web/Controllers/ChartsController.cs +++ b/Finjector.Web/Controllers/ChartsController.cs @@ -146,15 +146,6 @@ public async Task SaveChart([FromBody] ChartViewModel chartViewMo ? await _dbContext.Folders.SingleAsync(f => f.Id == chartViewModel.FolderId) : await _userService.GetPersonalFolder(iamId); - // TODO: do we want to update the coa detail here? do an extra query for up to date info? send more from the client? - var coaDetail = await _dbContext.CoaDetails.SingleOrDefaultAsync(cd => cd.Id == chartViewModel.SegmentString); - - if (coaDetail == null) - { - coaDetail = chartViewModel.SegmentString.ToCoADetail(); - - await _dbContext.CoaDetails.AddAsync(coaDetail); - } // get the chart or create a new one Coa chart; @@ -171,7 +162,6 @@ public async Task SaveChart([FromBody] ChartViewModel chartViewMo chart.Folder = folderToUse; chart.SegmentString = chartViewModel.SegmentString; - chart.Detail = coaDetail; chart.Name = chartViewModel.Name; chart.ChartType = chartViewModel.ChartType; chart.Updated = DateTime.UtcNow; From 7bc347699123e4a37774316dd7450bf290373b2e Mon Sep 17 00:00:00 2001 From: Jason Sylvestre Date: Tue, 9 Apr 2024 09:50:13 -0700 Subject: [PATCH 2/4] Specifically log exception on save --- Finjector.Web/Controllers/ChartsController.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Finjector.Web/Controllers/ChartsController.cs b/Finjector.Web/Controllers/ChartsController.cs index dc72a3d9..975ae349 100644 --- a/Finjector.Web/Controllers/ChartsController.cs +++ b/Finjector.Web/Controllers/ChartsController.cs @@ -8,6 +8,7 @@ using Finjector.Core.Extensions; using Finjector.Web.Handlers; using Microsoft.EntityFrameworkCore; +using Serilog; namespace Finjector.Web.Controllers; @@ -165,9 +166,16 @@ public async Task SaveChart([FromBody] ChartViewModel chartViewMo chart.Name = chartViewModel.Name; chart.ChartType = chartViewModel.ChartType; chart.Updated = DateTime.UtcNow; - - await _dbContext.SaveChangesAsync(); - + try + { + await _dbContext.SaveChangesAsync(); + } + catch (Exception ex) + { + //var error = ex.Message; + Log.Error(ex, "Error saving chart"); + throw; + } return Ok(chart); } From b0e9acfb66d971e30daffc7bd925c820a319c739 Mon Sep 17 00:00:00 2001 From: Jason Sylvestre Date: Tue, 9 Apr 2024 09:56:19 -0700 Subject: [PATCH 3/4] Migration --- ...20240409165535_removeCoaDetail.Designer.cs | 417 ++++++++++++++++++ .../20240409165535_removeCoaDetail.cs | 69 +++ .../AppDbContextSqlServerModelSnapshot.cs | 121 ----- 3 files changed, 486 insertions(+), 121 deletions(-) create mode 100644 Finjector.Core/Migrations/20240409165535_removeCoaDetail.Designer.cs create mode 100644 Finjector.Core/Migrations/20240409165535_removeCoaDetail.cs diff --git a/Finjector.Core/Migrations/20240409165535_removeCoaDetail.Designer.cs b/Finjector.Core/Migrations/20240409165535_removeCoaDetail.Designer.cs new file mode 100644 index 00000000..430122c8 --- /dev/null +++ b/Finjector.Core/Migrations/20240409165535_removeCoaDetail.Designer.cs @@ -0,0 +1,417 @@ +// +using System; +using Finjector.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Finjector.Core.Migrations +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240409165535_removeCoaDetail")] + partial class removeCoaDetail + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.24") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("Finjector.Core.Domain.Coa", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartType") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("FolderId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("SegmentString") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("FolderId"); + + b.ToTable("Coas"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Folder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TeamId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TeamId"); + + b.ToTable("Folders"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.FolderPermission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("FolderId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FolderId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("FolderPermissions"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FolderId") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FolderId"); + + b.HasIndex("TeamId"); + + b.HasIndex("UserId"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Team", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsPersonal") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.TeamPermission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("TeamId"); + + b.HasIndex("UserId"); + + b.ToTable("TeamPermissions"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Kerberos") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Coa", b => + { + b.HasOne("Finjector.Core.Domain.Folder", "Folder") + .WithMany("Coas") + .HasForeignKey("FolderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Folder"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Folder", b => + { + b.HasOne("Finjector.Core.Domain.Team", "Team") + .WithMany("Folders") + .HasForeignKey("TeamId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.FolderPermission", b => + { + b.HasOne("Finjector.Core.Domain.Folder", "Folder") + .WithMany("FolderPermissions") + .HasForeignKey("FolderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Finjector.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Finjector.Core.Domain.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Folder"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.History", b => + { + b.HasOne("Finjector.Core.Domain.Folder", "Folder") + .WithMany() + .HasForeignKey("FolderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Finjector.Core.Domain.Team", "Team") + .WithMany() + .HasForeignKey("TeamId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Finjector.Core.Domain.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Folder"); + + b.Navigation("Team"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Team", b => + { + b.HasOne("Finjector.Core.Domain.User", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.TeamPermission", b => + { + b.HasOne("Finjector.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Finjector.Core.Domain.Team", "Team") + .WithMany("TeamPermissions") + .HasForeignKey("TeamId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Finjector.Core.Domain.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("Team"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Folder", b => + { + b.Navigation("Coas"); + + b.Navigation("FolderPermissions"); + }); + + modelBuilder.Entity("Finjector.Core.Domain.Team", b => + { + b.Navigation("Folders"); + + b.Navigation("TeamPermissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Finjector.Core/Migrations/20240409165535_removeCoaDetail.cs b/Finjector.Core/Migrations/20240409165535_removeCoaDetail.cs new file mode 100644 index 00000000..3f0c83cd --- /dev/null +++ b/Finjector.Core/Migrations/20240409165535_removeCoaDetail.cs @@ -0,0 +1,69 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Finjector.Core.Migrations +{ + public partial class removeCoaDetail : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Coas_CoaDetails_SegmentString", + table: "Coas"); + + migrationBuilder.DropTable( + name: "CoaDetails"); + + migrationBuilder.DropIndex( + name: "IX_Coas_SegmentString", + table: "Coas"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "CoaDetails", + columns: table => new + { + Id = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Activity = table.Column(type: "nvarchar(6)", maxLength: 6, nullable: false), + ActivityDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + ChartType = table.Column(type: "nvarchar(3)", maxLength: 3, nullable: false), + Department = table.Column(type: "nvarchar(7)", maxLength: 7, nullable: false), + DepartmentDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Entity = table.Column(type: "nvarchar(4)", maxLength: 4, nullable: false), + EntityDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Fund = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + FundDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + NaturalAccount = table.Column(type: "nvarchar(6)", maxLength: 6, nullable: false), + NaturalAccountDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Program = table.Column(type: "nvarchar(3)", maxLength: 3, nullable: false), + ProgramDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Project = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: false), + ProjectDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Purpose = table.Column(type: "nvarchar(2)", maxLength: 2, nullable: false), + PurposeDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Task = table.Column(type: "nvarchar(6)", maxLength: 6, nullable: false), + TaskDetails = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CoaDetails", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Coas_SegmentString", + table: "Coas", + column: "SegmentString"); + + migrationBuilder.AddForeignKey( + name: "FK_Coas_CoaDetails_SegmentString", + table: "Coas", + column: "SegmentString", + principalTable: "CoaDetails", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Finjector.Core/Migrations/AppDbContextSqlServerModelSnapshot.cs b/Finjector.Core/Migrations/AppDbContextSqlServerModelSnapshot.cs index 6026c48b..067e0d0e 100644 --- a/Finjector.Core/Migrations/AppDbContextSqlServerModelSnapshot.cs +++ b/Finjector.Core/Migrations/AppDbContextSqlServerModelSnapshot.cs @@ -55,117 +55,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("FolderId"); - b.HasIndex("SegmentString"); - b.ToTable("Coas"); }); - modelBuilder.Entity("Finjector.Core.Domain.CoaDetail", b => - { - b.Property("Id") - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("Activity") - .IsRequired() - .HasMaxLength(6) - .HasColumnType("nvarchar(6)"); - - b.Property("ActivityDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ChartType") - .IsRequired() - .HasMaxLength(3) - .HasColumnType("nvarchar(3)"); - - b.Property("Department") - .IsRequired() - .HasMaxLength(7) - .HasColumnType("nvarchar(7)"); - - b.Property("DepartmentDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Entity") - .IsRequired() - .HasMaxLength(4) - .HasColumnType("nvarchar(4)"); - - b.Property("EntityDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Fund") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); - - b.Property("FundDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("NaturalAccount") - .IsRequired() - .HasMaxLength(6) - .HasColumnType("nvarchar(6)"); - - b.Property("NaturalAccountDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Program") - .IsRequired() - .HasMaxLength(3) - .HasColumnType("nvarchar(3)"); - - b.Property("ProgramDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Project") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("ProjectDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Purpose") - .IsRequired() - .HasMaxLength(2) - .HasColumnType("nvarchar(2)"); - - b.Property("PurposeDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Task") - .IsRequired() - .HasMaxLength(6) - .HasColumnType("nvarchar(6)"); - - b.Property("TaskDetails") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("CoaDetails"); - }); - modelBuilder.Entity("Finjector.Core.Domain.Folder", b => { b.Property("Id") @@ -399,14 +291,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Finjector.Core.Domain.CoaDetail", "Detail") - .WithMany("Coas") - .HasForeignKey("SegmentString") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Detail"); - b.Navigation("Folder"); }); @@ -512,11 +396,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("User"); }); - modelBuilder.Entity("Finjector.Core.Domain.CoaDetail", b => - { - b.Navigation("Coas"); - }); - modelBuilder.Entity("Finjector.Core.Domain.Folder", b => { b.Navigation("Coas"); From 945f78a96dda914de893e676ec4e26cb5811272e Mon Sep 17 00:00:00 2001 From: Jason Sylvestre Date: Tue, 9 Apr 2024 10:19:06 -0700 Subject: [PATCH 4/4] Migrate if in release mode --- Finjector.Web/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Finjector.Web/Program.cs b/Finjector.Web/Program.cs index 7e8f41e9..8fed128e 100644 --- a/Finjector.Web/Program.cs +++ b/Finjector.Web/Program.cs @@ -189,7 +189,9 @@ var context = services.GetRequiredService(); var initialize = new DbInitializer(context); initialize.Initialize().GetAwaiter().GetResult(); - //context.Database.Migrate(); +#if RELEASE + context.Database.Migrate(); +#endif } catch (Exception ex) {