fix(db): update migration and configure many-to-many relationships to avoid cascade paths

- Regenerated InitialCreate migration to reflect new entity configurations
- Configured many-to-many relationship between CostCycle and Unit with NoAction on Unit side to prevent multiple cascade paths
- Updated UnitCost relationships: Cascade from CostCycle, NoAction from Unit
- Removed commented-out global filter code and replaced with explicit relationship configurations
This commit is contained in:
2026-06-09 02:23:09 +03:30
parent 569e39b58d
commit 6644db7e78
5 changed files with 61 additions and 52 deletions

View File

@@ -200,8 +200,8 @@ using (var scope = app.Services.CreateScope())
"BEGIN " + "BEGIN " +
"CREATE TABLE [__EFMigrationsHistory] ([MigrationId] nvarchar(150) NOT NULL, [ProductVersion] nvarchar(32) NOT NULL, PRIMARY KEY ([MigrationId])); " + "CREATE TABLE [__EFMigrationsHistory] ([MigrationId] nvarchar(150) NOT NULL, [ProductVersion] nvarchar(32) NOT NULL, PRIMARY KEY ([MigrationId])); " +
"END " + "END " +
"IF NOT EXISTS (SELECT * FROM __EFMigrationsHistory WHERE MigrationId = '20260608224155_InitialCreate') " + "IF NOT EXISTS (SELECT * FROM __EFMigrationsHistory WHERE MigrationId = '20260608225159_InitialCreate') " +
"INSERT INTO __EFMigrationsHistory (MigrationId, ProductVersion) VALUES ('20260608224155_InitialCreate', '6.0.3')"); "INSERT INTO __EFMigrationsHistory (MigrationId, ProductVersion) VALUES ('20260608225159_InitialCreate', '6.0.3')");
} }
} }
catch catch

View File

@@ -53,19 +53,30 @@ namespace Complex.Infrastructure
builder.Entity<Unit>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false); builder.Entity<Unit>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false);
builder.Entity<UnitCost>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false); builder.Entity<UnitCost>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false);
builder.Entity<CostCycle>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false); builder.Entity<CostCycle>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false);
//builder.ApplyGlobalFilters<bool>("IsRemoved", false);
// var allEntities = modelBuilder.Model.GetEntityTypes();
//Expression<Func<IMutableEntityType, bool>> filterExpr = bm => (bm.GetProperty("IsRemoved").ToString() == "0");
//foreach (var entity in builder.Model.GetEntityTypes())
//{
// //if (!entity.ClrType.IsAssignableTo(typeof(BaseEntity)))
// // continue;
// if (entity.ClrType.GetCustomAttributes(typeof(AuditableAttribute), true).Length > 0) // Configure many-to-many between CostCycle and Unit
// entity // SQL Server does not allow multiple cascade paths, so one side must use NoAction
// //entity.SetQueryFilter(filterExpr); builder.Entity<CostCycle>()
//} .HasMany(cc => cc.Units)
.WithMany(u => u.CostCycles)
.UsingEntity<Dictionary<string, object>>(
"CostCycleUnit",
j => j.HasOne<Unit>().WithMany().HasForeignKey("UnitsId").OnDelete(DeleteBehavior.NoAction),
j => j.HasOne<CostCycle>().WithMany().HasForeignKey("CostCyclesId").OnDelete(DeleteBehavior.Cascade));
// Configure UnitCost relationships to avoid multiple cascade paths
// UnitCost -> CostCycle (Cascade) and UnitCost -> Unit (NoAction)
builder.Entity<UnitCost>()
.HasOne(uc => uc.CostCycle)
.WithMany()
.HasForeignKey(uc => uc.CostCycleId)
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<UnitCost>()
.HasOne(uc => uc.Unit)
.WithMany()
.HasForeignKey(uc => uc.UnitId)
.OnDelete(DeleteBehavior.NoAction);
} }

View File

@@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Complex.Infrastructure.Migrations namespace Complex.Infrastructure.Migrations
{ {
[DbContext(typeof(ComplexDBContext))] [DbContext(typeof(ComplexDBContext))]
[Migration("20260608224155_InitialCreate")] [Migration("20260608225159_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -119,7 +119,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(350)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(1882));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -178,7 +178,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(2221)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(3884));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -254,7 +254,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(3082)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(4981));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -306,7 +306,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(4033)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(6348));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -349,7 +349,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(5727)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(8225));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -397,7 +397,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(7277)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 647, DateTimeKind.Local).AddTicks(86));
b.Property<bool>("IsActive") b.Property<bool>("IsActive")
.HasColumnType("bit"); .HasColumnType("bit");
@@ -517,7 +517,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(9359)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 648, DateTimeKind.Local).AddTicks(3522));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -588,7 +588,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(1589)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 649, DateTimeKind.Local).AddTicks(412));
b.Property<bool>("IsActive") b.Property<bool>("IsActive")
.HasColumnType("bit"); .HasColumnType("bit");
@@ -659,7 +659,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(3756)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 649, DateTimeKind.Local).AddTicks(6073));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -705,7 +705,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(4973)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 650, DateTimeKind.Local).AddTicks(161));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -949,7 +949,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", "Unit") b.HasOne("Complex.Domain.Entities.Unit", "Unit")
.WithMany() .WithMany()
.HasForeignKey("UnitId") .HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.NoAction)
.IsRequired(); .IsRequired();
b.Navigation("CostCycle"); b.Navigation("CostCycle");
@@ -979,7 +979,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", null) b.HasOne("Complex.Domain.Entities.Unit", null)
.WithMany() .WithMany()
.HasForeignKey("UnitsId") .HasForeignKey("UnitsId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.NoAction)
.IsRequired(); .IsRequired();
}); });

View File

@@ -51,7 +51,7 @@ namespace Complex.Infrastructure.Migrations
RegisterMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: false), RegisterMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Body = table.Column<string>(type: "nvarchar(max)", nullable: false), Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true), Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(3082)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(4981)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -71,7 +71,7 @@ namespace Complex.Infrastructure.Migrations
Gender = table.Column<byte>(type: "tinyint", nullable: true), Gender = table.Column<byte>(type: "tinyint", nullable: true),
Avatar = table.Column<byte[]>(type: "varbinary(max)", nullable: true), Avatar = table.Column<byte[]>(type: "varbinary(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false), IsActive = table.Column<bool>(type: "bit", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(7277)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 647, DateTimeKind.Local).AddTicks(86)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -135,7 +135,7 @@ namespace Complex.Infrastructure.Migrations
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false), Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Icon = table.Column<string>(type: "nvarchar(max)", nullable: false), Icon = table.Column<string>(type: "nvarchar(max)", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(4973)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 650, DateTimeKind.Local).AddTicks(161)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -223,7 +223,7 @@ namespace Complex.Infrastructure.Migrations
ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true), Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
CityId = table.Column<int>(type: "int", nullable: false), CityId = table.Column<int>(type: "int", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(350)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(1882)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -254,7 +254,7 @@ namespace Complex.Infrastructure.Migrations
ManagerMobileNumberId = table.Column<string>(type: "nvarchar(450)", nullable: true), ManagerMobileNumberId = table.Column<string>(type: "nvarchar(450)", nullable: true),
StartDate = table.Column<string>(type: "nvarchar(max)", nullable: false), StartDate = table.Column<string>(type: "nvarchar(max)", nullable: false),
EndDate = table.Column<string>(type: "nvarchar(max)", nullable: false), EndDate = table.Column<string>(type: "nvarchar(max)", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(2221)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(3884)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -285,7 +285,7 @@ namespace Complex.Infrastructure.Migrations
TransactionTypeId = table.Column<int>(type: "int", nullable: false), TransactionTypeId = table.Column<int>(type: "int", nullable: false),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
RegisterMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: true), RegisterMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(5727)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(8225)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -324,7 +324,7 @@ namespace Complex.Infrastructure.Migrations
StateId = table.Column<int>(type: "int", nullable: true), StateId = table.Column<int>(type: "int", nullable: true),
Floor = table.Column<int>(type: "int", nullable: true), Floor = table.Column<int>(type: "int", nullable: true),
ManagerDescription = table.Column<string>(type: "nvarchar(max)", nullable: true), ManagerDescription = table.Column<string>(type: "nvarchar(max)", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(1589)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 649, DateTimeKind.Local).AddTicks(412)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -368,7 +368,7 @@ namespace Complex.Infrastructure.Migrations
EncouragementDay = table.Column<int>(type: "int", nullable: false), EncouragementDay = table.Column<int>(type: "int", nullable: false),
EncouragementAmount = table.Column<long>(type: "bigint", nullable: false), EncouragementAmount = table.Column<long>(type: "bigint", nullable: false),
IncomeCostTitleId = table.Column<int>(type: "int", nullable: true), IncomeCostTitleId = table.Column<int>(type: "int", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(4033)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(6348)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -409,8 +409,7 @@ namespace Complex.Infrastructure.Migrations
name: "FK_CostCycleUnit_Units_UnitsId", name: "FK_CostCycleUnit_Units_UnitsId",
column: x => x.UnitsId, column: x => x.UnitsId,
principalTable: "Units", principalTable: "Units",
principalColumn: "Id", principalColumn: "Id");
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
@@ -423,7 +422,7 @@ namespace Complex.Infrastructure.Migrations
UnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), UnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TransactionId = table.Column<int>(type: "int", nullable: true), TransactionId = table.Column<int>(type: "int", nullable: true),
Date = table.Column<DateTime>(type: "date", nullable: false), Date = table.Column<DateTime>(type: "date", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(3756)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 649, DateTimeKind.Local).AddTicks(6073)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
@@ -441,8 +440,7 @@ namespace Complex.Infrastructure.Migrations
name: "FK_UnitCosts_Units_UnitId", name: "FK_UnitCosts_Units_UnitId",
column: x => x.UnitId, column: x => x.UnitId,
principalTable: "Units", principalTable: "Units",
principalColumn: "Id", principalColumn: "Id");
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
@@ -462,7 +460,7 @@ namespace Complex.Infrastructure.Migrations
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UnitCostId = table.Column<long>(type: "bigint", nullable: false), UnitCostId = table.Column<long>(type: "bigint", nullable: false),
PersonId = table.Column<string>(type: "nvarchar(450)", nullable: false), PersonId = table.Column<string>(type: "nvarchar(450)", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(9359)), InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 21, 59, 648, DateTimeKind.Local).AddTicks(3522)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true), RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true) UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)

View File

@@ -117,7 +117,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(350)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(1882));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -176,7 +176,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(2221)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(3884));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -252,7 +252,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(3082)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(4981));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -304,7 +304,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(4033)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(6348));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -347,7 +347,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(5727)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 646, DateTimeKind.Local).AddTicks(8225));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -395,7 +395,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(7277)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 647, DateTimeKind.Local).AddTicks(86));
b.Property<bool>("IsActive") b.Property<bool>("IsActive")
.HasColumnType("bit"); .HasColumnType("bit");
@@ -515,7 +515,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 153, DateTimeKind.Local).AddTicks(9359)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 648, DateTimeKind.Local).AddTicks(3522));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -586,7 +586,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(1589)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 649, DateTimeKind.Local).AddTicks(412));
b.Property<bool>("IsActive") b.Property<bool>("IsActive")
.HasColumnType("bit"); .HasColumnType("bit");
@@ -657,7 +657,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(3756)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 649, DateTimeKind.Local).AddTicks(6073));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -703,7 +703,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime") b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 11, 55, 154, DateTimeKind.Local).AddTicks(4973)); .HasDefaultValue(new DateTime(2026, 6, 9, 2, 21, 59, 650, DateTimeKind.Local).AddTicks(161));
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -947,7 +947,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", "Unit") b.HasOne("Complex.Domain.Entities.Unit", "Unit")
.WithMany() .WithMany()
.HasForeignKey("UnitId") .HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.NoAction)
.IsRequired(); .IsRequired();
b.Navigation("CostCycle"); b.Navigation("CostCycle");
@@ -977,7 +977,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", null) b.HasOne("Complex.Domain.Entities.Unit", null)
.WithMany() .WithMany()
.HasForeignKey("UnitsId") .HasForeignKey("UnitsId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.NoAction)
.IsRequired(); .IsRequired();
}); });