From a318f69883955b56016597e0bae78a0c2fb7cc51 Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Sun, 4 May 2025 13:33:56 +0530 Subject: [PATCH] Do not populate activity master during migration --- .../Data/ApplicationDbContext.cs | 138 +++++++++--------- .../20250501162003_Initmigration.cs | 18 +-- 2 files changed, 71 insertions(+), 85 deletions(-) diff --git a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs index 0db8812..333dafb 100644 --- a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs +++ b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs @@ -9,7 +9,6 @@ using Marco.Pms.Model.Forum; using Marco.Pms.Model.Industries; using Marco.Pms.Model.Projects; using Marco.Pms.Model.Utilities; -using Marco.Pms.Utility; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; @@ -189,77 +188,80 @@ namespace Marco.Pms.DataAccess.Data EndDate = DateTime.ParseExact("2026-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), ProjectStatusId = new Guid("b74da4c2-d07e-46f2-9919-e75e49b12731"), TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new Project - { - Id = new Guid("3ef56a12-f5e5-4193-87d6-9e110ed10b86"), - Name = "Project 2", - ProjectAddress = "Project 2 Address", - ContactPerson = "Project 2 Contact Person", - StartDate = DateTime.ParseExact("2025-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), - EndDate = DateTime.ParseExact("2026-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), - ProjectStatusId = new Guid("ef1c356e-0fe0-42df-a5d3-8daee355492d"), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new Project - { - Id = new Guid("54d013e3-0a2b-48be-85c7-5ef03492a18c"), - Name = "Project 3", - ProjectAddress = "Project 3 Address", - ContactPerson = "Project 3 Contact Person", - StartDate = DateTime.ParseExact("2025-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), - EndDate = DateTime.ParseExact("2026-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), - ProjectStatusId = new Guid("33deaef9-9af1-4f2a-b443-681ea0d04f81"), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }); + } + //, new Project + //{ + // Id = new Guid("3ef56a12-f5e5-4193-87d6-9e110ed10b86"), + // Name = "Project 2", + // ProjectAddress = "Project 2 Address", + // ContactPerson = "Project 2 Contact Person", + // StartDate = DateTime.ParseExact("2025-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), + // EndDate = DateTime.ParseExact("2026-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), + // ProjectStatusId = new Guid("ef1c356e-0fe0-42df-a5d3-8daee355492d"), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + //}, new Project + //{ + // Id = new Guid("54d013e3-0a2b-48be-85c7-5ef03492a18c"), + // Name = "Project 3", + // ProjectAddress = "Project 3 Address", + // ContactPerson = "Project 3 Contact Person", + // StartDate = DateTime.ParseExact("2025-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), + // EndDate = DateTime.ParseExact("2026-04-20 10:11:17.588000", "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture), + // ProjectStatusId = new Guid("33deaef9-9af1-4f2a-b443-681ea0d04f81"), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + //} + ); var tenantId = _httpContextAccessor.HttpContext?.Items["TenantId"]?.ToString(); - modelBuilder.Entity() - .HasData( - new ActivityMaster - { - Id = new Guid("4117b7de-ef6c-461f-a2c2-64eaac5f9a11"), - ActivityName = "Core Cutting", - UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new ActivityMaster - { - Id = new Guid("1714f64d-7591-4419-bee5-118d21bb2855"), - ActivityName = "Fabrication", - UnitOfMeasurement = UnitOfMeasurement.Meter.ToString(), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new ActivityMaster - { - Id = new Guid("b3f51a93-dde6-45f9-8b22-f1bf017a640b"), - ActivityName = "Welding", - UnitOfMeasurement = UnitOfMeasurement.Meter.ToString(), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new ActivityMaster - { - Id = new Guid("53eedf44-4076-445f-be93-fedef17117e7"), - ActivityName = "MS Support Fabrication", - UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new ActivityMaster - { - Id = new Guid("715b9ddb-d9e2-4afa-8987-d9918905cea4"), - ActivityName = "MS Support Hanging", - UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new ActivityMaster - { - Id = new Guid("a3d191a7-a5aa-4dd8-a525-12c99263bbd6"), - ActivityName = "Hydrant Volve", - UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - }, new ActivityMaster - { - Id = new Guid("c138a7de-713a-4bd4-8292-b0b265be77a3"), - ActivityName = "Sprinkler Installation", - UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), - TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") - } - ); + //modelBuilder.Entity() + // .HasData( + // new ActivityMaster + // { + // Id = new Guid("4117b7de-ef6c-461f-a2c2-64eaac5f9a11"), + // ActivityName = "Core Cutting", + // UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + // }, new ActivityMaster + // { + // Id = new Guid("1714f64d-7591-4419-bee5-118d21bb2855"), + // ActivityName = "Fabrication", + // UnitOfMeasurement = UnitOfMeasurement.Meter.ToString(), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + // }, new ActivityMaster + // { + // Id = new Guid("b3f51a93-dde6-45f9-8b22-f1bf017a640b"), + // ActivityName = "Welding", + // UnitOfMeasurement = UnitOfMeasurement.Meter.ToString(), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + // }, new ActivityMaster + // { + // Id = new Guid("53eedf44-4076-445f-be93-fedef17117e7"), + // ActivityName = "MS Support Fabrication", + // UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + // }, new ActivityMaster + // { + // Id = new Guid("715b9ddb-d9e2-4afa-8987-d9918905cea4"), + // ActivityName = "MS Support Hanging", + // UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + // }, new ActivityMaster + // { + // Id = new Guid("a3d191a7-a5aa-4dd8-a525-12c99263bbd6"), + // ActivityName = "Hydrant Volve", + // UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + // }, new ActivityMaster + // { + // Id = new Guid("c138a7de-713a-4bd4-8292-b0b265be77a3"), + // ActivityName = "Sprinkler Installation", + // UnitOfMeasurement = UnitOfMeasurement.Number.ToString(), + // TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") + // } + // ); + modelBuilder.Entity().HasData( new Industry { Id = Guid.Parse("15436ee3-a650-469e-bfc2-59993f7514bb"), Name = "Information Technology (IT) Services" }, new Industry { Id = Guid.Parse("0a63e657-2c5f-49b5-854b-42c978293154"), Name = "Manufacturing & Production" }, diff --git a/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs b/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs index fddc3ff..eb6b5d3 100644 --- a/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs +++ b/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -1341,19 +1340,6 @@ namespace Marco.Pms.DataAccess.Migrations columns: new[] { "Id", "ContactName", "ContactNumber", "Description", "DomainName", "IndustryId", "IsActive", "Name", "OnBoardingDate", "OragnizationSize" }, values: new object[] { new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Admin", "123456789", "", "www.marcobms.org", new Guid("15436ee3-a650-469e-bfc2-59993f7514bb"), true, "MarcoBMS", new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "100-200" }); - migrationBuilder.InsertData( - table: "ActivityMasters", - columns: new[] { "Id", "ActivityName", "IsActive", "TenantId", "UnitOfMeasurement" }, - values: new object[,] - { - { new Guid("1714f64d-7591-4419-bee5-118d21bb2855"), "Fabrication", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Meter" }, - { new Guid("4117b7de-ef6c-461f-a2c2-64eaac5f9a11"), "Core Cutting", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Number" }, - { new Guid("53eedf44-4076-445f-be93-fedef17117e7"), "MS Support Fabrication", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Number" }, - { new Guid("715b9ddb-d9e2-4afa-8987-d9918905cea4"), "MS Support Hanging", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Number" }, - { new Guid("a3d191a7-a5aa-4dd8-a525-12c99263bbd6"), "Hydrant Volve", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Number" }, - { new Guid("b3f51a93-dde6-45f9-8b22-f1bf017a640b"), "Welding", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Meter" }, - { new Guid("c138a7de-713a-4bd4-8292-b0b265be77a3"), "Sprinkler Installation", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26"), "Number" } - }); migrationBuilder.InsertData( table: "FeaturePermissions", @@ -1396,8 +1382,6 @@ namespace Marco.Pms.DataAccess.Migrations columns: new[] { "Id", "ContactPerson", "EndDate", "Name", "ProjectAddress", "ProjectStatusId", "StartDate", "TenantId" }, values: new object[,] { - { new Guid("3ef56a12-f5e5-4193-87d6-9e110ed10b86"), "Project 2 Contact Person", new DateTime(2026, 4, 20, 10, 11, 17, 588, DateTimeKind.Unspecified), "Project 2", "Project 2 Address", new Guid("ef1c356e-0fe0-42df-a5d3-8daee355492d"), new DateTime(2025, 4, 20, 10, 11, 17, 588, DateTimeKind.Unspecified), new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, - { new Guid("54d013e3-0a2b-48be-85c7-5ef03492a18c"), "Project 3 Contact Person", new DateTime(2026, 4, 20, 10, 11, 17, 588, DateTimeKind.Unspecified), "Project 3", "Project 3 Address", new Guid("33deaef9-9af1-4f2a-b443-681ea0d04f81"), new DateTime(2025, 4, 20, 10, 11, 17, 588, DateTimeKind.Unspecified), new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, { new Guid("85bf587b-7ca9-4685-b77c-d817f5847e85"), "Project 1 Contact Person", new DateTime(2026, 4, 20, 10, 11, 17, 588, DateTimeKind.Unspecified), "Project 1", "Project 1 Address", new Guid("b74da4c2-d07e-46f2-9919-e75e49b12731"), new DateTime(2025, 4, 20, 10, 11, 17, 588, DateTimeKind.Unspecified), new Guid("b3466e83-7e11-464c-b93a-daf047838b26") } });